forked from eclipse-cyclonedds/cyclonedds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
latency-test-extract
executable file
·95 lines (85 loc) · 2.75 KB
/
latency-test-extract
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/perl -w
# Note: this is specialized for async delivery, listener mode because of the way it deals with
# thread names
use strict;
my %res = ();
my %meas;
while (<>) {
next unless s/^\[\d+\] \d+\.\d+\s+//;
if (s/^[^\@:]+:\d+\s+size (\d+) //) {
# size is always the first line of an output block
# ddsperf doesn't print CPU loads, RSS, bandwidth if it is zero
my %tmp = %meas;
push @{$res{$meas{size}}}, \%tmp if %meas;
%meas = (size => $1,
rawxmitbw => 0, rawrecvbw => 0,
subrss => 0, pubrss => 0,
subcpu => 0, subrecv => 0,
pubcpu => 0, pubrecv => 0);
$meas{$1} = $2 while s/^(mean|min|max|\d+%)\s+(\d+\.\d+)us\s*//;
die unless /cnt \d+$/;
} elsif (s/^(\@[^:]+:\d+\s+)?rss:(\d+\.\d+)([kM])B//) {
my $side = defined $1 ? "pub" : "sub";
$meas{"${side}rss"} = $2 / ($3 eq "k" ? 1024.0 : 1);
$meas{"${side}cpu"} = cpuload (($side eq "pub") ? "pub" : "dq.user", $_);
$meas{"${side}recv"} = cpuload ("recvUC", $_);
} elsif (/xmit\s+(\d+)%\s+recv\s+(\d+)%/) {
$meas{rawxmitbw} = $1;
$meas{rawrecvbw} = $2;
}
}
push @{$res{$meas{size}}}, \%meas if %meas;
die "no data found" unless keys %res > 0;
print "#size mean min 50% 90% 99% max rawxmitbw rawrecvbw pubrss subrss pubcpu pubrecv subcpu subrecv\n";
my @sizes = sort { $a <=> $b } keys %res;
for my $sz (@sizes) {
my $ms = $res{$sz};
my $min = min ("min", $ms);
my $max = max ("max", $ms);
my $mean = mean ("mean", $ms); # roughly same number of roundtrips, so not too far off
my $median = max ("50%", $ms); # also not quite correct ...
my $p90 = max ("90%", $ms);
my $p99 = max ("99%", $ms);
my $rawxmitbw = median ("rawxmitbw", $ms);
my $rawrecvbw = median ("rawrecvbw", $ms);
my $pubrss = max ("pubrss", $ms);
my $subrss = max ("subrss", $ms);
my $pubcpu = median ("pubcpu", $ms);
my $pubrecv = median ("pubrecv", $ms);
my $subcpu = median ("subcpu", $ms);
my $subrecv = median ("subrecv", $ms);
print "$sz $mean $min $median $p90 $p99 $max $rawxmitbw $rawrecvbw $pubrss $subrss $pubcpu $pubrecv $subcpu $subrecv\n";
}
sub cpuload {
my ($thread, $line) = @_;
$thread =~ s/\./\\./g;
if ($line =~ /$thread:(\d+)%\+(\d+)%/) {
return $1+$2;
} else {
return 0;
}
}
sub max {
my $v;
for (extract (@_)) { $v = $_ unless defined $v; $v = $_ if $_ > $v; }
return $v;
}
sub min {
my $v;
for (extract (@_)) { $v = $_ unless defined $v; $v = $_ if $_ < $v; }
return $v;
}
sub mean {
my $v = 0;
my @xs = extract (@_);
$v += $_ for @xs;
return $v / @xs;
}
sub median {
my @xs = sort { $a <=> $b } (extract (@_));
return (@xs % 2) ? $xs[(@xs - 1) / 2] : ($xs[@xs/2 - 1] + $xs[@xs/2]) / 2;
}
sub extract {
my ($key, $msref) = @_;
return map { $_->{$key} } @$msref;
}