-
Notifications
You must be signed in to change notification settings - Fork 5
/
was_count_shake.pl
executable file
·70 lines (58 loc) · 1.85 KB
/
was_count_shake.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl
# Approximate SSL handshake times given WAS SSLChannel trace.
use strict;
use HTTP::Date; # part of LWP
my @finished = ();
my %pending = ();
my $line = 0;
my $state = "stackstart";
# Convert WAS timestampes for short deltas.
sub my_str2time {
my $timestr = $_[0];
my $rv = str2time($timestr);
if ($timestr =~ /(\d+:\d+:\d+):(\d\d\d )/) {
$rv = str2time("Wed, 09 Feb 1994 $1");
$rv += $2/1000;
}
return $rv;
}
while(<>) {
$line = 0 if eof;
if ($_ =~ m/\[(.*)\] ([0-9a-f]+) SSLUtils.*handleHandshake.*Entry/) {
# print "$_\n";
my $file = $ARGV;
my $t = my_str2time($1);
if (defined($pending{$2})) {
die ("already saw $_");
}
my $v = { file=>$file, start=> $t, startpretty=>$1, pidtid=>$2, begin_line=>$line};
$pending{$2} = $v;
}
elsif ($_ =~ m/\[(.*)\] ([0-9a-f]+) SSLUtils.*handleHandshake Exit/) {
# print "$_\n";
my $t = my_str2time($1);
if (!defined($pending{$2})) {
print STDERR "handshake didn't start $_\n";
$line++;
next;
}
my $start = $pending{$2}->{'start'};
my $v = { start=>$start, startpretty=>$pending{$2}->{'startpretty'}, pidtid=>$2, stop=>$t, delta=> ($t - $start),
file=>$pending{$2}->{'file'},
end_line=>$line, begin_line=>$pending{$2}->{'begin_line'} };
push @finished, $v;
$pending{$2} = undef;
}
$line++;
}
my $r;
foreach $r (@finished) {
my $delta = sprintf "%.4fs", $r->{'delta'} ;
my $sed = sed_split($r);
print "$delta, $r->{'startpretty'}, $r->{'pidtid'}, \"$sed\"\n";
}
sub sed_split() {
my ($r) = @_;
return sprintf "sed -e '%s,%s!d' '%s' | grep '%s'",
$r->{'begin_line'}, $r->{'end_line'}, $r->{'file'} , $r->{'pidtid'};
}