X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Futils%2Fbabelstats.pl;h=8dbb7a32fbf5770e8808364dbd703270c3aed205;hp=64a243fc8a69f8b1428d8bf7c5a2231cc8756afd;hb=0b5a4de9aa05787410e50ce238ceb199a642154d;hpb=815535ae5260a74761a0df31aab4d55917b002d4 diff --git a/tests/utils/babelstats.pl b/tests/utils/babelstats.pl index 64a243fc8..8dbb7a32f 100755 --- a/tests/utils/babelstats.pl +++ b/tests/utils/babelstats.pl @@ -1,19 +1,9 @@ #!/usr/bin/perl -# Copyright (C) - 2012 Christian Babeux +# Copyright (C) 2012 Christian Babeux # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. +# SPDX-License-Identifier: GPL-2.0-only # -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; use warnings; @@ -92,9 +82,8 @@ sub merge_fields my %merged; foreach my $event (@{$events_ref}) { - my $tp_provider = $event->{'tp_provider'}; - my $tp_name = $event->{'tp_name'}; - my $tracepoint = "$tp_provider:$tp_name"; + my $tp_event = $event->{'tp_event'}; + my $tracepoint = "${tp_event}"; foreach my $key (keys %{$event->{'fields'}}) { my $val = $event->{'fields'}->{$key}; @@ -118,7 +107,7 @@ sub print_fields_stats foreach my $field (keys %{$merged_ref->{$tracepoint}}) { my @sorted; - my @val = keys ($merged_ref->{$tracepoint}->{$field}); + my @val = keys %{$merged_ref->{$tracepoint}->{$field}}; if ($val[0] =~ /^\d+$/) { # Sort numerically @@ -142,33 +131,18 @@ my @events; while (<>) { - my $timestamp = '\[(.*)\]'; - my $elapsed = '\((.*)\)'; - my $hostname = '.*'; - my $pname = '.*'; - my $pinfo = '.*'; - my $pid = '\d+'; - my $tp_provider = '.*'; - my $tp_name = '.*'; - my $cpu_info = '{\scpu_id\s=\s(\d+)\s\}'; - my $fields = '{(.*)}'; + my $timestamp = '\[(?:.*)\]'; + my $elapsed = '\((?:.*)\)'; + my $hostname = '(?:.*)'; + my $tp_event = '(.*)'; + my $pkt_context = '(?:\{[^}]*\},\s)*'; + my $fields = '\{(.*)\}$'; # Parse babeltrace text output format - if (/$timestamp\s$elapsed\s($pinfo)\s($tp_provider):($tp_name):\s$cpu_info,\s$fields/) { + if (/$timestamp\s$elapsed\s$hostname\s$tp_event:\s$pkt_context$fields/) { my %event_hash; - $event_hash{'timestamp'} = $1; - $event_hash{'elapsed'} = $2; - $event_hash{'pinfo'} = $3; - -# my @split_pinfo = split(':', $3); -# $event_hash{'hostname'} = $split_pinfo[0]; -# $event_hash{'pname'} = defined($split_pinfo[1]) ? $split_pinfo[1] : undef; -# $event_hash{'pid'} = defined($split_pinfo[2]) ? $split_pinfo[2] : undef; - - $event_hash{'tp_provider'} = $4; - $event_hash{'tp_name'} = $5; - $event_hash{'cpu_id'} = $6; - $event_hash{'fields'} = parse_fields($7); + $event_hash{'tp_event'} = $1; + $event_hash{'fields'} = parse_fields($2); push @events, \%event_hash; }