]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/perf/perldriver/Output.pm
3 # ********************************************************************
4 # * Copyright (C) 2016 and later: Unicode, Inc. and others.
5 # * License & terms of use: http://www.unicode.org/copyright.html#License
6 # ********************************************************************
7 # ********************************************************************
9 # * Copyright (c) 2002, International Business Machines Corporation and
10 # * others. All Rights Reserved.
11 # ********************************************************************
18 my $TABLEATTR = 'BORDER="1" CELLPADDING="4" CELLSPACING="0"' ;
23 my @timetypes = ( "mean per op" , "error per op" , "events" , "per event" );
27 my $mult = 1e9 ; #use nanoseconds
28 my $perc = 100 ; #for percent
30 my $legend = "<a name= \" Legend \" > \n <h2>Table legend</h2></a><ul>" ;
33 my $operationIs = "operation" ;
34 my $eventIs = "event" ;
45 foreach $message ( @_ ) {
46 $legend .= "<li>" . $message . "</li> \n " ;
54 my $mean = $value -> getMean ;
55 my $error = $value -> getError ;
56 print HTML
"<td class= \" " ;
64 print HTML formatPercent
( 2 , $mean );
66 print HTML formatNumber
( 2 , $mult , $mean );
69 print HTML
"<td class= \" " ;
70 if ((( $error*$mult < 10 )&&! $percent ) || (( $error < 10 )&& $percent )) {
73 print HTML
"errorLarge" ;
75 print HTML
" \" >±" ;
77 print HTML formatPercent
( 2 , $error );
79 print HTML formatNumber
( 2 , $mult , $error );
86 print HTML
"<td class= \" sepvalue \" >" ;
88 #print HTML formatNumber(2, 1, $value);
93 #my $printEvents = shift;
96 print HTML
"<table $TABLEATTR > \n " ;
97 print HTML
"<tbody> \n " ;
101 print HTML
"<th rowspan= \" 2 \" class= \" testNameHeader \" ><a href= \" #TestName \" >Test Name</a></th> \n " ;
102 print HTML
"<th rowspan= \" 2 \" class= \" testNameHeader \" ><a href= \" #Ops \" >Ops</a></th> \n " ;
103 printLeg
( "<a name= \" Test Name \" >TestName</a> - name of the test as set by the test writer \n " , "<a name= \" Ops \" >Ops</a> - number of " . $operationIs . "s per iteration \n " );
105 print HTML
"<th colspan=" .(( 4 *( $#headers+1 ))- 2 ). " class= \" sourceType \" >Per Operation</th> \n " ;
107 print HTML
"<th colspan=" .(( 2 *( $#headers+1 ))- 2 ). " class= \" sourceType \" >Per Operation</th> \n " ;
108 print HTML
"<th colspan=" .(( 5 *( $#headers+1 ))- 2 ). " class= \" sourceType \" >Per Event</th> \n " ;
110 print HTML
"</tr> \n <tr> \n " ;
112 foreach $header ( @headers ) {
113 print HTML
"<th class= \" source \" colspan=2><a href= \" #meanop_ $header \" > $header <br>/op</a></th> \n " ;
114 printLeg
( "<a name= \" meanop_ $header \" > $header /op</a> - mean time and error for $header per $operationIs " );
117 for $i ( 1 .. $#headers ) {
118 print HTML
"<th class= \" source \" colspan=2><a href= \" #mean_op_ $i \" >ratio $i <br>/op</a></th> \n " ;
119 printLeg
( "<a name= \" mean_op_ $i \" >ratio $i /op</a> - ratio and error of per $operationIs time, calculated as: (( $headers [0] - $headers [ $i ])/ $headers [ $i ])*100%, mean value" );
122 foreach $header ( @headers ) {
123 print HTML
"<th class= \" source \" ><a href= \" #events_ $header \" > $header <br>events</a></th> \n " ;
124 printLeg
( "<a name= \" events_ $header \" > $header events</a> - number of " . $eventIs . "s for $header per iteration" );
126 foreach $header ( @headers ) {
127 print HTML
"<th class= \" source \" colspan=2><a href= \" #mean_ev_ $header \" > $header <br>/ev</a></th> \n " ;
128 printLeg
( "<a name= \" mean_ev_ $header \" > $header /ev</a> - mean time and error for $header per $eventIs " );
130 for $i ( 1 .. $#headers ) {
131 print HTML
"<th class= \" source \" colspan=2><a href= \" #mean_ev_ $i \" >ratio $i <br>/ev</a></th> \n " ;
132 printLeg
( "<a name= \" mean_ev_ $i \" >ratio $i /ev</a> - ratio and error of per $eventIs time, calculated as: (( $headers [0] - $headers [ $i ])/ $headers [ $i ])*100%, mean value" );
135 print HTML
"</tr> \n " ;
143 print HTML
"</tr> \n " ;
144 print HTML
"</tbody>" ;
145 print HTML
"</table> \n " ;
153 print HTML
"</tr> \n " ;
164 print HTML
" align = $align >" ;
172 foreach $message ( @_ ) {
173 print HTML
" $message " ;
179 my $date = localtime ;
181 %options = %{ $options };
182 my $title = $options { "title" };
183 my $headers = $options { "headers" };
184 if ( $options { "operationIs" }) {
185 $operationIs = $options { "operationIs" };
187 if ( $options { "eventIs" }) {
188 $eventIs = $options { "eventIs" };
190 @headers = split ( / / , $headers );
192 ( $t , $rest ) = split ( /\.\w+/ , $0 );
195 if ( $outType eq 'HTML' ) {
197 $html =~ s/://g ; # ':' illegal
198 $html =~ s/\s*\d+$// ; # delete year
199 $html =~ s/^\w+\s*// ; # delete dow
200 $html = " $t $html .html" ;
201 if ( $options { "outputDir" }) {
202 $html = $options { "outputDir" }. "/" . $html ;
206 open ( HTML
, "> $html " ) or die "Can't write to $html : $! " ;
208 #<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
212 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
213 <TITLE> $title </TITLE>
216 body { font-size: 10pt; font-family: sans-serif }
217 th { font-size: 10pt; border: 0 solid #000080; padding: 5 }
218 th.testNameHeader { border-width: 1 }
219 th.testName { text-align: left; border-left-width: 1; border-right-width: 1;
220 border-bottom-width: 1 }
221 th.source { border-right-width: 1; border-bottom-width: 1 }
222 th.sourceType { border-right-width: 1; border-top-width: 1; border-bottom-width: 1 }
223 td { font-size: 10pt; text-align: Right; border: 0 solid #000080; padding: 5 }
224 td.string { text-align: Left; border-bottom-width:1; border-right-width:1 }
225 td.sepvalue { border-bottom-width: 1; border-right-width: 1 }
226 td.value { border-bottom-width: 1 }
227 td.worse { color: #FF0000; font-weight: bold; border-bottom-width: 1 }
228 td.error { font-size: 75%; border-right-width: 1; border-bottom-width: 1 }
229 td.errorLarge { font-size: 75%; color: #FF0000; font-weight: bold; border-right-width: 1;
230 border-bottom-width: 1 }
231 A:link { color: black; font-weight: normal; text-decoration: none} /* unvisited links */
232 A:visited { color: blue; font-weight: normal; text-decoration: none } /* visited links */
233 A:hover { color: red; font-weight: normal; text-decoration: none } /* user hovers */
234 A:active { color: lime; font-weight: normal; text-decoration: none } /* active links */
238 <BODY bgcolor="#FFFFFF" LINK="#006666" VLINK="#000000">
240 print HTML
"<H1> $title </H1> \n " ;
242 #print HTML "<H2>$TESTCLASS</H2>\n";
247 if ( $outType eq 'HTML' ) {
251 $legend .= "</ul> \n " ;
258 close ( HTML
) or die "Can't close $html : $! " ;
264 print HTML
"<h2>Raw data</h2>" ;
269 print HTML
"<table $TABLEATTR > \n " ;
270 for $key ( sort keys %raw ) {
272 $printkey =~ s/\<br\>/ /g ;
275 print HTML
"<tr><th class= \" testNameHeader \" colspan = 7> $printkey </td></tr> \n " ; # locale and data file
277 print HTML
"<tr><th class= \" testName \" >test name</th><th class= \" testName \" >interesting arguments</th><th class= \" testName \" >iterations</th><th class= \" testName \" >operations</th><th class= \" testName \" >mean time (ns)</th><th class= \" testName \" >error (ns)</th><th class= \" testName \" >events</th></tr> \n " ;
280 print HTML
"<tr><th class= \" testName \" colspan = 6> $printkey </td></tr> \n " ; # locale and data file
282 print HTML
"<tr><th class= \" testName \" >test name</th><th class= \" testName \" >interesting arguments</th><th class= \" testName \" >iterations</th><th class= \" testName \" >operations</th><th class= \" testName \" >mean time (ns)</th><th class= \" testName \" >error (ns)</th></tr> \n " ;
284 $printkey =~ s/[\<\>\/ ]/ / g
;
287 for $i ( $raw { $key } ) {
291 ( $test , $args ) = split ( /,/ , shift ( @$j ));
293 print HTML
"<th class= \" testName \" >" ;
295 print HTML
"<a name= \" " . $printkey . "_" . $test . " \" >" . $test . "</a>" ;
302 print HTML
"<td class= \" string \" >" . $args . "</td>" ;
304 print HTML
"<td class= \" sepvalue \" >" . shift ( @$j ). "</td>" ;
305 print HTML
"<td class= \" sepvalue \" >" . shift ( @$j ). "</td>" ;
307 my @data = @{ shift ( @$j ) };
308 my $ds = Dataset-
> new ( @data );
309 print HTML
"<td class= \" sepvalue \" >" . formatNumber
( 4 , $mult , $ds -> getMean ). "</td><td class= \" sepvalue \" >" . formatNumber
( 4 , $mult , $ds -> getError ). "</td>" ;
311 print HTML
"<td class= \" sepvalue \" >" . shift ( @$j ). "</td>" ;
313 print HTML
"</tr> \n " ;
320 $raw { $current }[ $exp++ ] = [ @_ ];
324 #$raw{$current}[$exp++] = [@_];
325 my $testName = shift ;
326 my @iterPerPass = @{ shift ( @_ )};
327 my @noopers = @{ shift ( @_ )};
328 my @timedata = @{ shift ( @_ )};
331 @noevents = @{ shift ( @_ )};
341 debug
( "No events: @noevents , $#noevents \n " );
345 $loc =~ s/\<br\>/ /g ;
346 $loc =~ s/[\<\>\/ ]/ / g
;
348 # Finished one row of results. Outputting
350 #outputData($testName, "LEFT");
351 print HTML
"<th class= \" testName \" ><a href= \" #" . $loc . "_" . $testName . " \" > $testName </a></th> \n " ;
352 #outputData($iterCount);
353 #outputData($noopers[0], "RIGHT");
354 outputValue
( $noopers [ 0 ]);
357 for $j ( 0 .. $#timedata ) {
358 my $perOperation = $timedata [ $j ]-> divideByScalar ( $iterPerPass [ $j ]* $noopers [ $j ]); # time per operation
359 #debug("Time per operation: ".formatSeconds(4, $perOperation->getMean, $perOperation->getError)."\n");
360 outputDist
( $perOperation );
363 my $baseLinePO = $timedata [ 0 ]-> divideByScalar ( $iterPerPass [ 0 ]* $noopers [ 0 ]);
364 for $j ( 1 .. $#timedata ) {
365 my $perOperation = $timedata [ $j ]-> divideByScalar ( $iterPerPass [ $j ]* $noopers [ $j ]); # time per operation
366 my $ratio = $baseLinePO -> subtract ( $perOperation );
367 $ratio = $ratio -> divide ( $perOperation );
368 outputDist
( $ratio , "%" );
371 for $j ( 0 .. $#timedata ) {
372 #outputData($noevents[$j], "RIGHT");
373 outputValue
( $noevents [ $j ]);
375 for $j ( 0 .. $#timedata ) {
376 my $perEvent = $timedata [ $j ]-> divideByScalar ( $iterPerPass [ $j ]* $noevents [ $j ]); # time per event
377 #debug("Time per operation: ".formatSeconds(4, $perEvent->getMean, $perEvent->getError)."\n");
378 outputDist
( $perEvent );
380 my $baseLinePO = $timedata [ 0 ]-> divideByScalar ( $iterPerPass [ 0 ]* $noevents [ 0 ]);
381 for $j ( 1 .. $#timedata ) {
382 my $perOperation = $timedata [ $j ]-> divideByScalar ( $iterPerPass [ $j ]* $noevents [ $j ]); # time per operation
383 my $ratio = $baseLinePO -> subtract ( $perOperation );
384 $ratio = $ratio -> divide ( $perOperation );
385 outputDist
( $ratio , "%" );