Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / re2 / benchlog / mktable
blobda0659820c8d9a8aadf4ffe1d04ec0f8bb2c6bad
1 #!/usr/bin/perl
2 # XXX
4 sub table() {
5 my ($name) = @_;
6 print <<'EOF';
7 <table border=0>
8 <tr><th>System</th><th>PCRE</th><th>RE2</th></tr>
9 EOF
10 foreach my $sys (@sys) {
11 my $ns_pcre = $data{$sys}->{sprintf($name, "PCRE")}->{'ns/op'};
12 my $ns_re2 = $data{$sys}->{sprintf($name, "RE2")}->{'ns/op'};
13 printf "<tr><td>%s</td><td>%.1f µs</td><td>%.1f µs</td></tr>\n", $sysname{$sys}, $ns_pcre/1000., $ns_re2/1000.;
15 print <<'EOF';
16 <tr height=5><td colspan=3></td></tr>
17 </table>
18 EOF
21 @sizes = (
22 "8", "16", "32", "64", "128", "256", "512",
23 "1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K",
24 "1M", "2M", "4M", "8M", "16M"
27 %color = (
28 "PCRE" => "0.7 0 0",
29 "RE2" => "0 0 1",
32 $ngraph = 0;
34 sub graph() {
35 my ($name) = @_;
37 my $sys = "wreck";
38 my $base = sprintf("regexp3g%d", ++$ngraph);
40 open(JGR, ">$base.jgr") || die "open >$base.jgr: $!";
41 printf JGR "bbox -20 -12 392 95\n";
42 printf JGR "newgraph clip x_translate 0.25 y_translate 0.25\n";
43 $ymax = 0;
44 %lastx = ();
45 %lasty = ();
46 foreach my $who ("PCRE", "RE2") {
47 printf JGR "newcurve pts\n";
48 for(my $i=0; $i<@sizes; $i++) {
49 my $key = sprintf("%s%s/%s", $name, $who, $sizes[$i]);
50 my $val = $data{$sys}->{$key}->{'MB/s'};
51 next if !defined($val);
52 if($val > $ymax) {
53 $ymax = $val;
55 $lastx{$who} = $i;
56 $lasty{$who} = $val;
57 printf JGR "$i %f (* %s *)\n", $val, $key;
59 my $color = $color{$who};
60 printf JGR "marktype none color $color linethickness 2 linetype solid label : $who\n";
62 my $n = @sizes;
63 printf JGR "xaxis min -1 max $n size 5 label : text size (bytes)\n";
64 printf JGR " no_auto_hash_marks hash_labels fontsize 9\n";
65 for($i=0; $i<@sizes; $i+=3) {
66 printf JGR " hash_at $i hash_label at $i : $sizes[$i]\n";
68 my $y = 1;
69 while(10*$y <= $ymax) {
70 $y = 10*$y;
72 for($i=2; $i<=10; $i++) {
73 if($i*$y > $ymax) {
74 $y = $i*$y;
75 last;
78 foreach my $who ("PCRE", "RE2") {
79 $x1 = $lastx{$who};
80 $y1 = $lasty{$who};
81 $x1 *= 1.01;
82 my $v = "vjc";
83 if($y1 < 0.05 * $y) {
84 $v = "vjb";
85 $y1 = 0.05 * $y;
87 printf JGR "newstring x $x1 y $y1 hjl $v : $who\n";
89 printf JGR "yaxis min 0 max $y size 1 label : speed (MB/s)\n";
90 printf JGR " hash_labels fontsize 9\n";
91 # printf JGR "legend defaults font Times-Roman fontsize 10 x 0 y $y hjl vjt\n";
93 system("jgraph $base.jgr >$base.eps"); # die "system: $!";
94 system("gs -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dEPSCrop -sDEVICE=png16m -r100 -sOutputFile=$base.png -dBATCH -dQUIT -dQUIET -dNOPAUSE $base.eps");
96 printf "<img src=$base.png>\n"
100 sub skip() {
101 while(<>) {
102 if(/^<!-- -->/) {
103 print;
104 last;
109 @sys = ("r70", "c2", "wreck", "mini");
110 %sysname = (
111 "r70" => "AMD Opteron 8214 HE, 2.2 GHz",
112 "c2" => "Intel Core2 Duo E7200, 2.53 GHz",
113 "wreck" => "Intel Xeon 5150, 2.66 GHz (Mac Pro)",
114 "mini" => "Intel Core2 T5600, 1.83 GHz (Mac Mini)",
117 %func = (
118 "table" => \&table,
119 "graph" => \&graph,
123 foreach my $sys (@sys) {
124 open(F, "benchlog.$sys") || die "open benchlog.$sys: $!";
125 my %sysdat;
126 while(<F>) {
127 if(/^([A-Za-z0-9_\/]+)\s+(\d+)\s+(\d+) ns\/op/) {
128 my %row;
129 $row{"name"} = $1;
130 $row{"iter"} = $2;
131 $row{"ns/op"} = $3;
132 if(/([\d.]+) MB\/s/){
133 $row{"MB/s"} = $1;
135 $sysdat{$row{"name"}} = \%row;
138 close F;
139 $data{$sys} = \%sysdat;
142 while(<>) {
143 print;
144 if(/^<!-- benchlog (\w+) -->/) {
145 $func{$1}();
146 skip();
147 next;
149 if(/^<!-- benchlog (\w+) ([%\w]+) -->/) {
150 $func{$1}($2);
151 skip();
152 next;