File tree Expand file tree Collapse file tree 3 files changed +59
-2
lines changed
bench/benchmark-interface/lib Expand file tree Collapse file tree 3 files changed +59
-2
lines changed Original file line number Diff line number Diff line change 12
12
require 'benchmark-interface/frontends/mri'
13
13
require 'benchmark-interface/backends/simple'
14
14
require 'benchmark-interface/backends/stable'
15
+ require 'benchmark-interface/backends/fixed-iterations'
15
16
require 'benchmark-interface/backends/benchmark'
16
17
require 'benchmark-interface/backends/bips'
17
18
require 'benchmark-interface/backends/bench9000'
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. This
2
+ # code is released under a tri EPL/GPL/LGPL license. You can use it,
3
+ # redistribute it and/or modify it under the terms of the:
4
+ #
5
+ # Eclipse Public License version 2.0, or
6
+ # GNU General Public License version 2, or
7
+ # GNU Lesser General Public License version 2.1.
8
+
9
+ module BenchmarkInterface
10
+ module Backends
11
+ module FixedIterations
12
+
13
+ def self . get_time
14
+ Process . clock_gettime ( Process ::CLOCK_MONOTONIC )
15
+ end
16
+
17
+ def self . run ( benchmark_set , names , options )
18
+ print_iterations = options [ '--iterations' ]
19
+ elapsed = options [ '--elapsed' ]
20
+ print_ips = options [ '--ips' ]
21
+
22
+ fixed_iterations = options [ '--fixed-iterations' ] . sort
23
+ total_iterations = fixed_iterations . last
24
+
25
+ benchmark_set . benchmarks ( names ) . each do |benchmark |
26
+ puts benchmark . name
27
+ block = benchmark . block
28
+
29
+ next_iter = fixed_iterations . shift
30
+ start_time = get_time
31
+ ( 1 ..total_iterations ) . each do |iter |
32
+ block . call
33
+
34
+ if iter == next_iter
35
+ since_start = get_time - start_time
36
+ puts iter if print_iterations
37
+ puts since_start if elapsed
38
+ puts iter / since_start if print_ips
39
+
40
+ next_iter = fixed_iterations . shift
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+ end
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ def self.run(args)
30
30
'--freq' => 1 ,
31
31
'--elapsed' => false ,
32
32
'--iterations' => false ,
33
+ '--ips' => false ,
34
+ '--fixed-iterations' => [ ] ,
33
35
'--log' => nil ,
34
36
'--tag' => [ ] ,
35
37
'--prop' => { }
@@ -49,6 +51,9 @@ def self.run(args)
49
51
backend = BenchmarkInterface ::Backends ::Simple
50
52
when '--stable'
51
53
backend = BenchmarkInterface ::Backends ::Stable
54
+ when '--fixed-iterations'
55
+ backend = BenchmarkInterface ::Backends ::FixedIterations
56
+ options [ arg ] = args [ n += 1 ] . split ( ',' ) . map { |iter | Integer ( iter ) }
52
57
when '--bips'
53
58
backend = BenchmarkInterface ::Backends ::Bips
54
59
when '--bm'
@@ -72,6 +77,8 @@ def self.run(args)
72
77
n += 1
73
78
when '--elapsed'
74
79
options [ arg ] = true
80
+ when '--ips'
81
+ options [ arg ] = true
75
82
when '--log'
76
83
options [ arg ] = args [ n + 1 ]
77
84
n += 1
@@ -148,9 +155,10 @@ def self.help
148
155
puts ' list list benchmarks available in the files'
149
156
puts
150
157
puts 'Backends:'
151
- puts ' --simple'
158
+ puts ' --simple (default) '
152
159
puts ' --stable'
153
- puts ' --bips (default)'
160
+ puts ' --fixed-iterations ITERS1,ITERS2,...'
161
+ puts ' --bips'
154
162
puts ' --bm'
155
163
puts ' --bmbm'
156
164
puts ' --bench9000'
You can’t perform that action at this time.
0 commit comments