mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
Added utility [#METR-2944].
This commit is contained in:
parent
632608dae7
commit
e1e652338f
49
utils/postprocess-traces/postprocess-traces.pl
Executable file
49
utils/postprocess-traces/postprocess-traces.pl
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
my @current_stack = ();
|
||||
my $grouped_stacks = {};
|
||||
|
||||
while (my $line = <>)
|
||||
{
|
||||
chomp $line;
|
||||
|
||||
if ($line =~ '^#')
|
||||
{
|
||||
$line =~ s/^#\d+\s+//;
|
||||
$line =~ s/ \([^\)]+=[^\)]+\) / /g;
|
||||
push @current_stack, $line;
|
||||
}
|
||||
|
||||
if ($line eq '')
|
||||
{
|
||||
my $group = \$grouped_stacks;
|
||||
for my $frame (reverse @current_stack)
|
||||
{
|
||||
$$group->{count} ||= 0;
|
||||
++$$group->{count};
|
||||
$group = \$$group->{children}{$frame};
|
||||
}
|
||||
|
||||
@current_stack = ();
|
||||
}
|
||||
}
|
||||
|
||||
sub print_group
|
||||
{
|
||||
my $group = shift;
|
||||
my $level = shift || 0;
|
||||
|
||||
for my $key (sort { $group->{children}{$b}{count} <=> $group->{children}{$a}{count} } keys %{$group->{children}})
|
||||
{
|
||||
my $count = $group->{count};
|
||||
print(('| ' x $level) . $count . (' ' x (5 - (length $count))) . $key . "\n");
|
||||
print_group($group->{children}{$key}, $level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
print_group($grouped_stacks);
|
Loading…
Reference in New Issue
Block a user