@@ -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
@@ -270,8 +273,25 @@ def filterLines(self, lines):
270
273
271
274
def runBenchmark (self , benchmark , bmSuiteArgs ):
272
275
arguments = ['benchmark' ]
273
- arguments .extend (['--simple' , '--elapsed' , '--iterations' ])
274
- arguments .extend (['--time' , str (self .time ())])
276
+ if self .config ()['kind' ] == 'simple' :
277
+ arguments .extend (['--simple' , '--elapsed' , '--iterations' ])
278
+ time = self .time ()
279
+ if isinstance (time , dict ):
280
+ if benchmark in time :
281
+ time = str (time [benchmark ])
282
+ else :
283
+ time = str (time ['default' ])
284
+ else :
285
+ time = str (self .time ())
286
+ arguments .extend (['--time' , time ])
287
+ elif self .config ()['kind' ] == 'fixed-iterations' :
288
+ iterations_arg = ',' .join ([str (i ) for i in sorted (self .config ()['iterations' ][benchmark ].keys ())])
289
+ arguments .extend (['--elapsed' , '--iterations' , '--ips' ])
290
+ arguments .extend (['--fixed-iterations' ])
291
+ arguments .extend ([iterations_arg ])
292
+ else :
293
+ raise AssertionError ("Unknown benchmark kind: " + self .config ()['kind' ])
294
+
275
295
if ':' in benchmark :
276
296
benchmark_file , benchmark_name = benchmark .split (':' )
277
297
benchmark_names = [benchmark_name ]
@@ -287,6 +307,7 @@ def runBenchmark(self, benchmark, bmSuiteArgs):
287
307
lines = out .data .split ('\n ' )[1 :- 1 ]
288
308
289
309
data = self .filterLines (lines )
310
+ iterations = [d for n , d in enumerate (data ) if n % 3 == 0 ]
290
311
elapsed = [d for n , d in enumerate (data ) if n % 3 == 1 ]
291
312
samples = [d for n , d in enumerate (data ) if n % 3 == 2 ]
292
313
@@ -311,6 +332,15 @@ def runBenchmark(self, benchmark, bmSuiteArgs):
311
332
'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
333
'error' : 'optimised away'
313
334
}]
335
+ elif self .config ()['kind' ] == 'fixed-iterations' :
336
+ iteration_config = self .config ()['iterations' ][benchmark ]
337
+ return [{
338
+ 'benchmark' : benchmark ,
339
+ 'metric.name' : iteration_config [iteration ],
340
+ 'metric.value' : e ,
341
+ 'metric.unit' : 's' ,
342
+ 'metric.better' : 'lower'
343
+ } for n , (e , iteration ) in enumerate (zip (elapsed , iterations )) if iteration in iteration_config ]
314
344
else :
315
345
return [{
316
346
'benchmark' : benchmark ,
@@ -469,15 +499,15 @@ def time(self):
469
499
'asciidoctor:string-lines' ,
470
500
'asciidoctor:read-line' ,
471
501
'asciidoctor:restore-line' ,
472
- 'asciidoctor:load-string' ,
473
- 'asciidoctor:load-file' ,
474
502
'asciidoctor:quote-match' ,
475
503
'asciidoctor:quote-sub' ,
476
504
'asciidoctor:join-lines' ,
477
- 'asciidoctor:convert'
505
+ 'asciidoctor-convert' ,
506
+ 'asciidoctor-load-file' ,
507
+ 'asciidoctor-load-string'
478
508
]
479
509
480
- asciidoctor_benchmark_time = 120
510
+ asciidoctor_benchmark_time = { 'asciidoctor-convert' : 400 , 'asciidoctor-load-file' : 400 , 'asciidoctor-load-string' : 400 , 'default' : 120 }
481
511
482
512
class AsciidoctorBenchmarkSuite (AllBenchmarksBenchmarkSuite ):
483
513
def name (self ):
@@ -642,6 +672,28 @@ def benchmarkList(self, bmSuiteArgs):
642
672
def time (self ):
643
673
return 60
644
674
675
+ asciidoctor_warmup_benchmarks = [
676
+ 'asciidoctor-convert' ,
677
+ 'asciidoctor-load-file' ,
678
+ 'asciidoctor-load-string'
679
+ ]
680
+
681
+ class AsciidoctorWarmupBenchmarkSuite (AllBenchmarksBenchmarkSuite ):
682
+ def config (self ):
683
+ iterations = {'asciidoctor-convert' : {10 :'startup' , 20 :'early-warmup' , 100 :'late-warmup' },
684
+ 'asciidoctor-load-file' : {10 :'startup' , 100 :'early-warmup' , 500 :'late-warmup' },
685
+ 'asciidoctor-load-string' : {10 :'startup' , 100 :'early-warmup' , 500 :'late-warmup' }}
686
+ return {'kind' : 'fixed-iterations' , 'iterations' : iterations }
687
+
688
+ def name (self ):
689
+ return 'asciidoctor-warmup'
690
+
691
+ def directory (self ):
692
+ return 'asciidoctor'
693
+
694
+ def benchmarkList (self , bmSuiteArgs ):
695
+ return asciidoctor_warmup_benchmarks
696
+
645
697
mx_benchmark .add_bm_suite (BuildStatsBenchmarkSuite ())
646
698
mx_benchmark .add_bm_suite (AllocationBenchmarkSuite ())
647
699
mx_benchmark .add_bm_suite (InstructionsBenchmarkSuite ())
@@ -660,3 +712,4 @@ def time(self):
660
712
mx_benchmark .add_bm_suite (ServerBenchmarkSuite ())
661
713
mx_benchmark .add_bm_suite (RubykonBenchmarkSuite ())
662
714
mx_benchmark .add_bm_suite (LiquidBenchmarkSuite ())
715
+ mx_benchmark .add_bm_suite (AsciidoctorWarmupBenchmarkSuite ())
0 commit comments