@@ -245,6 +245,9 @@ def runBenchmark(self, benchmark, bmSuiteArgs):
245
245
} for region , region_data in data .items () for n , sample in enumerate (region_data ['samples' ])]
246
246
247
247
class AllBenchmarksBenchmarkSuite (RubyBenchmarkSuite ):
248
+ def config (self ):
249
+ return {'kind' : 'simple' }
250
+
248
251
def benchmarkList (self , bmSuiteArgs ):
249
252
raise NotImplementedError ()
250
253
@@ -261,24 +264,48 @@ def filterLines(self, lines):
261
264
data = []
262
265
for line in lines :
263
266
try :
264
- data .append (float (line ))
267
+ data .append (int (line ))
265
268
except ValueError :
266
- mx .log_error (line )
269
+ try :
270
+ data .append (float (line ))
271
+ except ValueError :
272
+ mx .log_error (line )
267
273
if len (data ) % 3 != 0 :
268
274
raise AssertionError ("Number of values not a multiple of 3" )
269
275
return data
270
276
271
277
def runBenchmark (self , benchmark , bmSuiteArgs ):
278
+ directory = self .directory ()
279
+ if directory is None :
280
+ directory , benchmark = benchmark .split ('/' )
281
+
272
282
arguments = ['benchmark' ]
273
- arguments .extend (['--simple' , '--elapsed' , '--iterations' ])
274
- arguments .extend (['--time' , str (self .time ())])
283
+ if self .config ()['kind' ] == 'simple' :
284
+ arguments .extend (['--simple' , '--elapsed' , '--iterations' ])
285
+ time = self .time ()
286
+ if isinstance (time , dict ):
287
+ if benchmark in time :
288
+ time = str (time [benchmark ])
289
+ else :
290
+ time = str (time ['default' ])
291
+ else :
292
+ time = str (self .time ())
293
+ arguments .extend (['--time' , time ])
294
+ elif self .config ()['kind' ] == 'fixed-iterations' :
295
+ iterations_arg = ',' .join ([str (i ) for i in sorted (self .config ()['iterations' ][benchmark ].keys ())])
296
+ arguments .extend (['--elapsed' , '--iterations' , '--ips' ])
297
+ arguments .extend (['--fixed-iterations' ])
298
+ arguments .extend ([iterations_arg ])
299
+ else :
300
+ raise AssertionError ("Unknown benchmark kind: " + self .config ()['kind' ])
301
+
275
302
if ':' in benchmark :
276
303
benchmark_file , benchmark_name = benchmark .split (':' )
277
304
benchmark_names = [benchmark_name ]
278
305
else :
279
306
benchmark_file = benchmark
280
307
benchmark_names = []
281
- arguments .extend (['bench/' + self . directory () + '/' + benchmark_file + '.rb' ])
308
+ arguments .extend (['bench/' + directory + '/' + benchmark_file + '.rb' ])
282
309
arguments .extend (benchmark_names )
283
310
arguments .extend (bmSuiteArgs )
284
311
out = mx .OutputCapture ()
@@ -287,6 +314,7 @@ def runBenchmark(self, benchmark, bmSuiteArgs):
287
314
lines = out .data .split ('\n ' )[1 :- 1 ]
288
315
289
316
data = self .filterLines (lines )
317
+ iterations = [d for n , d in enumerate (data ) if n % 3 == 0 ]
290
318
elapsed = [d for n , d in enumerate (data ) if n % 3 == 1 ]
291
319
samples = [d for n , d in enumerate (data ) if n % 3 == 2 ]
292
320
@@ -311,6 +339,16 @@ def runBenchmark(self, benchmark, bmSuiteArgs):
311
339
'extra.metric.elapsed-num' : elapsed [- 1 ] + 2.0 if elapsed else 2.0 , # just put the data point beyond the last one a bit
312
340
'error' : 'optimised away'
313
341
}]
342
+ elif self .config ()['kind' ] == 'fixed-iterations' :
343
+ iteration_config = self .config ()['iterations' ][benchmark ]
344
+ return [{
345
+ 'benchmark' : benchmark ,
346
+ 'metric.name' : iteration_config [iteration ],
347
+ 'metric.iteration' : iteration ,
348
+ 'metric.value' : e ,
349
+ 'metric.unit' : 's' ,
350
+ 'metric.better' : 'lower'
351
+ } for n , (e , iteration ) in enumerate (zip (elapsed , iterations )) if iteration in iteration_config ]
314
352
else :
315
353
return [{
316
354
'benchmark' : benchmark ,
@@ -469,15 +507,20 @@ def time(self):
469
507
'asciidoctor:string-lines' ,
470
508
'asciidoctor:read-line' ,
471
509
'asciidoctor:restore-line' ,
472
- 'asciidoctor:load-string' ,
473
- 'asciidoctor:load-file' ,
474
510
'asciidoctor:quote-match' ,
475
511
'asciidoctor:quote-sub' ,
476
512
'asciidoctor:join-lines' ,
477
- 'asciidoctor:convert'
513
+ 'asciidoctor-convert' ,
514
+ 'asciidoctor-load-file' ,
515
+ 'asciidoctor-load-string'
478
516
]
479
517
480
- asciidoctor_benchmark_time = 120
518
+ asciidoctor_benchmark_time = {
519
+ 'asciidoctor-convert' : 400 ,
520
+ 'asciidoctor-load-file' : 400 ,
521
+ 'asciidoctor-load-string' : 400 ,
522
+ 'default' : 120
523
+ }
481
524
482
525
class AsciidoctorBenchmarkSuite (AllBenchmarksBenchmarkSuite ):
483
526
def name (self ):
@@ -642,6 +685,32 @@ def benchmarkList(self, bmSuiteArgs):
642
685
def time (self ):
643
686
return 60
644
687
688
+ warmup_benchmarks = [
689
+ 'asciidoctor/asciidoctor-convert' ,
690
+ 'asciidoctor/asciidoctor-load-file' ,
691
+ 'asciidoctor/asciidoctor-load-string' ,
692
+ 'rubykon/rubykon' ,
693
+ ]
694
+
695
+ class WarmupBenchmarkSuite (AllBenchmarksBenchmarkSuite ):
696
+ def config (self ):
697
+ iterations = {
698
+ 'asciidoctor-convert' : {10 :'startup' , 100 :'early-warmup' , 500 :'late-warmup' },
699
+ 'asciidoctor-load-file' : {10 :'startup' , 100 :'early-warmup' , 500 :'late-warmup' },
700
+ 'asciidoctor-load-string' : {10 :'startup' , 100 :'early-warmup' , 500 :'late-warmup' },
701
+ 'rubykon' : {1 :'startup' , 10 :'early-warmup' , 30 :'late-warmup' },
702
+ }
703
+ return {'kind' : 'fixed-iterations' , 'iterations' : iterations }
704
+
705
+ def name (self ):
706
+ return 'ruby-warmup'
707
+
708
+ def directory (self ):
709
+ return None
710
+
711
+ def benchmarkList (self , bmSuiteArgs ):
712
+ return warmup_benchmarks
713
+
645
714
mx_benchmark .add_bm_suite (BuildStatsBenchmarkSuite ())
646
715
mx_benchmark .add_bm_suite (AllocationBenchmarkSuite ())
647
716
mx_benchmark .add_bm_suite (InstructionsBenchmarkSuite ())
@@ -660,3 +729,4 @@ def time(self):
660
729
mx_benchmark .add_bm_suite (ServerBenchmarkSuite ())
661
730
mx_benchmark .add_bm_suite (RubykonBenchmarkSuite ())
662
731
mx_benchmark .add_bm_suite (LiquidBenchmarkSuite ())
732
+ mx_benchmark .add_bm_suite (WarmupBenchmarkSuite ())
0 commit comments