Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: third_party/re2/benchlog/mktable

Issue 10575037: Include RE2 library (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Less intrusive fix for Android Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/re2/benchlog/benchlog.wreck ('k') | third_party/re2/doc/README.xkcd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/perl
2 # XXX
3
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.;
14 }
15 print <<'EOF';
16 <tr height=5><td colspan=3></td></tr>
17 </table>
18 EOF
19 }
20
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"
25 );
26
27 %color = (
28 "PCRE" => "0.7 0 0",
29 "RE2" => "0 0 1",
30 );
31
32 $ngraph = 0;
33
34 sub graph() {
35 my ($name) = @_;
36
37 my $sys = "wreck";
38 my $base = sprintf("regexp3g%d", ++$ngraph);
39
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;
54 }
55 $lastx{$who} = $i;
56 $lasty{$who} = $val;
57 printf JGR "$i %f (* %s *)\n", $val, $key;
58 }
59 my $color = $color{$who};
60 printf JGR "marktype none color $color linethickness 2 linetype solid label : $who\n";
61 }
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";
67 }
68 my $y = 1;
69 while(10*$y <= $ymax) {
70 $y = 10*$y;
71 }
72 for($i=2; $i<=10; $i++) {
73 if($i*$y > $ymax) {
74 $y = $i*$y;
75 last;
76 }
77 }
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;
86 }
87 printf JGR "newstring x $x1 y $y1 hjl $v : $who\n";
88 }
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";
92
93 system("jgraph $base.jgr >$base.eps"); # die "system: $!";
94 system("gs -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dEPSCrop -sDEVICE=pn g16m -r100 -sOutputFile=$base.png -dBATCH -dQUIT -dQUIET -dNOPAUSE $base.eps");
95
96 printf "<img src=$base.png>\n"
97
98 }
99
100 sub skip() {
101 while(<>) {
102 if(/^<!-- -->/) {
103 print;
104 last;
105 }
106 }
107 }
108
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)",
115 );
116
117 %func = (
118 "table" => \&table,
119 "graph" => \&graph,
120
121 );
122
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;
134 }
135 $sysdat{$row{"name"}} = \%row;
136 }
137 }
138 close F;
139 $data{$sys} = \%sysdat;
140 }
141
142 while(<>) {
143 print;
144 if(/^<!-- benchlog (\w+) -->/) {
145 $func{$1}();
146 skip();
147 next;
148 }
149 if(/^<!-- benchlog (\w+) ([%\w]+) -->/) {
150 $func{$1}($2);
151 skip();
152 next;
153 }
154 }
155
OLDNEW
« no previous file with comments | « third_party/re2/benchlog/benchlog.wreck ('k') | third_party/re2/doc/README.xkcd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698