benchmark-interface 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +39 -0
  3. data/Gemfile +2 -0
  4. data/LICENCE +7 -0
  5. data/README.md +237 -0
  6. data/benchmark-interface.gemspec +20 -0
  7. data/bin/benchmark +15 -0
  8. data/examples/bench9000.rb +23 -0
  9. data/examples/bench9000micro.rb +31 -0
  10. data/examples/benchmark.rb +40 -0
  11. data/examples/bips.rb +34 -0
  12. data/examples/clamp.rb +17 -0
  13. data/examples/interface.rb +13 -0
  14. data/examples/long.rb +9 -0
  15. data/examples/mri.rb +15 -0
  16. data/examples/perfer.rb +25 -0
  17. data/examples/rbench.rb +46 -0
  18. data/examples/readme.rb +12 -0
  19. data/examples/script.rb +14 -0
  20. data/lib/benchmark-interface.rb +40 -0
  21. data/lib/benchmark-interface/backends/bench9000.rb +87 -0
  22. data/lib/benchmark-interface/backends/benchmark.rb +68 -0
  23. data/lib/benchmark-interface/backends/bips.rb +49 -0
  24. data/lib/benchmark-interface/backends/simple.rb +38 -0
  25. data/lib/benchmark-interface/benchmark-set.rb +85 -0
  26. data/lib/benchmark-interface/benchmark.rb +72 -0
  27. data/lib/benchmark-interface/frontends/bench9000.rb +21 -0
  28. data/lib/benchmark-interface/frontends/bench9000micro.rb +19 -0
  29. data/lib/benchmark-interface/frontends/benchmark.rb +50 -0
  30. data/lib/benchmark-interface/frontends/bips.rb +40 -0
  31. data/lib/benchmark-interface/frontends/mri.rb +84 -0
  32. data/lib/benchmark-interface/frontends/perfer.rb +27 -0
  33. data/lib/benchmark-interface/frontends/rbench.rb +64 -0
  34. data/lib/benchmark-interface/require.rb +38 -0
  35. data/lib/benchmark-interface/run.rb +111 -0
  36. data/lib/benchmark-interface/version.rb +13 -0
  37. data/tests/expected/bench9000-bips.txt +8 -0
  38. data/tests/expected/bench9000-bm.txt +2 -0
  39. data/tests/expected/bench9000-bmbm.txt +2 -0
  40. data/tests/expected/bench9000-simple.txt +2 -0
  41. data/tests/expected/bench9000micro-bips.txt +8 -0
  42. data/tests/expected/bench9000micro-bm.txt +2 -0
  43. data/tests/expected/bench9000micro-bmbm.txt +2 -0
  44. data/tests/expected/bench9000micro-simple.txt +2 -0
  45. data/tests/expected/benchmark-bips.txt +72 -0
  46. data/tests/expected/benchmark-bm.txt +12 -0
  47. data/tests/expected/benchmark-bmbm.txt +12 -0
  48. data/tests/expected/benchmark-simple.txt +22 -0
  49. data/tests/expected/bips-bips.txt +2 -0
  50. data/tests/expected/bips-bm.txt +7 -0
  51. data/tests/expected/bips-bmbm.txt +7 -0
  52. data/tests/expected/bips-simple.txt +11 -0
  53. data/tests/expected/interface-bips.txt +24 -0
  54. data/tests/expected/interface-bm.txt +4 -0
  55. data/tests/expected/interface-bmbm.txt +4 -0
  56. data/tests/expected/interface-simple.txt +6 -0
  57. data/tests/expected/long-bips.txt +9 -0
  58. data/tests/expected/long-bm.txt +2 -0
  59. data/tests/expected/long-bmbm.txt +2 -0
  60. data/tests/expected/long-simple.txt +2 -0
  61. data/tests/expected/mri-bips.txt +9 -0
  62. data/tests/expected/mri-bm.txt +2 -0
  63. data/tests/expected/mri-bmbm.txt +2 -0
  64. data/tests/expected/mri-simple.txt +2 -0
  65. data/tests/expected/perfer-bips.txt +20 -0
  66. data/tests/expected/perfer-bm.txt +4 -0
  67. data/tests/expected/perfer-bmbm.txt +4 -0
  68. data/tests/expected/perfer-simple.txt +5 -0
  69. data/tests/expected/rbench-bips.txt +42 -0
  70. data/tests/expected/rbench-bm.txt +7 -0
  71. data/tests/expected/rbench-bmbm.txt +7 -0
  72. data/tests/expected/rbench-simple.txt +12 -0
  73. data/tests/expected/readme-bips.txt +18 -0
  74. data/tests/expected/readme-bm.txt +3 -0
  75. data/tests/expected/readme-bmbm.txt +3 -0
  76. data/tests/expected/readme-simple.txt +4 -0
  77. data/tests/expected/script-bips.txt +18 -0
  78. data/tests/expected/script-bm.txt +3 -0
  79. data/tests/expected/script-bmbm.txt +3 -0
  80. data/tests/expected/script-simple.txt +4 -0
  81. data/tests/rewritten/mri.rb +15 -0
  82. data/tests/tests.rb +73 -0
  83. data/tests/tools/squash.rb +63 -0
  84. metadata +130 -0
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2016 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 1.0
6
+ # GNU General Public License version 2
7
+ # GNU Lesser General Public License version 2.1
8
+
9
+ module Kernel
10
+
11
+ alias_method :benchmark_interface_original_require, :require
12
+
13
+ def require(feature)
14
+ case feature
15
+ when 'benchmark'
16
+ benchmark_interface_original_require 'benchmark-interface/frontends/benchmark'
17
+ when 'benchmark/ips'
18
+ benchmark_interface_original_require 'benchmark-interface/frontends/bips'
19
+ when 'rbench'
20
+ benchmark_interface_original_require 'benchmark-interface/frontends/rbench'
21
+ when 'perfer'
22
+ benchmark_interface_original_require 'benchmark-interface/frontends/perfer'
23
+ when 'bench9000/harness', 'bench9000/micro-harness'
24
+ if BenchmarkInterface::Backends::Bench9000.loading_real?
25
+ # Do nothing
26
+ elsif feature == 'bench9000/harness'
27
+ benchmark_interface_original_require 'benchmark-interface/frontends/bench9000'
28
+ elsif feature == 'bench9000/micro-harness'
29
+ benchmark_interface_original_require 'benchmark-interface/frontends/bench9000micro'
30
+ end
31
+ when 'benchmark-interface'
32
+ # Already loaded by bin/benchmark
33
+ else
34
+ benchmark_interface_original_require feature
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,111 @@
1
+ # Copyright (c) 2016 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 1.0
6
+ # GNU General Public License version 2
7
+ # GNU Lesser General Public License version 2.1
8
+
9
+ module BenchmarkInterface
10
+
11
+ NON_MRI_INDICATORS = %w(
12
+ Benchmark.measure Benchmark.realtime Benchmark.benchmark Benchmark.bm
13
+ Benchmark.bmbm RBench.run Benchmark.ips Perfer.session harness_sample
14
+ )
15
+
16
+ def self.run(args)
17
+ set = BenchmarkInterface::BenchmarkSet.new
18
+
19
+ backend = BenchmarkInterface::Backends::Bips
20
+ names = []
21
+
22
+ options = {
23
+ '--no-scale' => false,
24
+ '--use-cache' => false,
25
+ '--show-rewrite' => false,
26
+ '--cache' => false,
27
+ '--time' => 10
28
+ }
29
+
30
+ to_load = []
31
+
32
+ n = 0
33
+ while n < args.size
34
+ arg = args[n]
35
+ if arg.start_with? '-'
36
+ case arg
37
+ when '--help', '-h', '-help', '--version', '-v', '-version'
38
+ help
39
+ when '--simple'
40
+ backend = BenchmarkInterface::Backends::Simple
41
+ when '--bips'
42
+ backend = BenchmarkInterface::Backends::Bips
43
+ when '--bm'
44
+ backend = BenchmarkInterface::Backends::Bm
45
+ when '--bmbm'
46
+ backend = BenchmarkInterface::Backends::BmBm
47
+ when '--bench9000'
48
+ backend = BenchmarkInterface::Backends::Bench9000
49
+ when '--time'
50
+ options[arg] = Integer(args[n + 1])
51
+ n += 1
52
+ else
53
+ abort "unknown option #{arg}" unless options.keys.include?(arg)
54
+ options[arg] = true
55
+ end
56
+ elsif arg.include?('.rb')
57
+ to_load.push arg
58
+ else
59
+ names.push arg
60
+ end
61
+ n += 1
62
+ end
63
+
64
+ to_load.each do |path|
65
+ source = File.read(path)
66
+ if NON_MRI_INDICATORS.any? { |t| source.include?(t) } || source =~ /benchmark.*\{/ || source =~ /benchmark.*do/
67
+ set.load_benchmarks path
68
+ else
69
+ set.load_mri_benchmarks path, options
70
+ end
71
+ end
72
+
73
+ set.prepare
74
+
75
+ if set.benchmarks.empty?
76
+ abort 'No benchmarks found!'
77
+ end
78
+
79
+ names.each do |name|
80
+ unless set.benchmark(name)
81
+ abort "Unknown benchmark #{name}"
82
+ end
83
+ end
84
+
85
+ names = set.benchmarks.map(&:name) if names.empty?
86
+
87
+ backend.run set, names, options
88
+ end
89
+
90
+ def self.help
91
+ puts "Benchmark-Interface #{VERSION}"
92
+ puts
93
+ puts 'benchmark benchmark-files.rb... [benchmark names...] [options]'
94
+ puts
95
+ puts 'Backends:'
96
+ puts ' --simple'
97
+ puts ' --bips (default)'
98
+ puts ' --bm'
99
+ puts ' --bmbm'
100
+ puts ' --bench9000'
101
+ puts
102
+ puts 'Options:'
103
+ puts ' --no-scale Don\'t scale benchmarks for backends that expects benchmarks to take about a second'
104
+ puts ' --show-rewrite Show rewritten MRI benchmarks'
105
+ puts ' --cache Cache MRI rewrites'
106
+ puts ' --use-cache Use cached MRI rewrites'
107
+ puts ' --time n Run for n seconds, if the backend supports that'
108
+ exit 1
109
+ end
110
+
111
+ end
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2016 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 1.0
6
+ # GNU General Public License version 2
7
+ # GNU Lesser General Public License version 2.1
8
+
9
+ module BenchmarkInterface
10
+
11
+ VERSION = '0.1'
12
+
13
+ end
@@ -0,0 +1,8 @@
1
+ Warming up --------------------------------------
2
+ bench9000 XXX i/100ms
3
+ bench9000 XXX i/100ms
4
+ bench9000 XXX i/100ms
5
+ Calculating -------------------------------------
6
+ bench9000 XXX (XXX%) i/s - XXX
7
+ bench9000 XXX (XXX%) i/s - XXX
8
+ bench9000 XXX (XXX%) i/s - XXX
@@ -0,0 +1,2 @@
1
+ user system total real
2
+ bench9000 XXX XXX XXX (XXX)
@@ -0,0 +1,2 @@
1
+ user system total real
2
+ bench9000 XXX XXX XXX (XXX)
@@ -0,0 +1,2 @@
1
+ bench9000
2
+ XXX
@@ -0,0 +1,8 @@
1
+ Warming up --------------------------------------
2
+ bench9000micro XXX i/100ms
3
+ bench9000micro XXX i/100ms
4
+ bench9000micro XXX i/100ms
5
+ Calculating -------------------------------------
6
+ bench9000micro XXX (XXX%) i/s - XXX
7
+ bench9000micro XXX (XXX%) i/s - XXX
8
+ bench9000micro XXX (XXX%) i/s - XXX
@@ -0,0 +1,2 @@
1
+ user system total real
2
+ bench9000micro XXX XXX XXX (XXX)
@@ -0,0 +1,2 @@
1
+ user system total real
2
+ bench9000micro XXX XXX XXX (XXX)
@@ -0,0 +1,2 @@
1
+ bench9000micro
2
+ XXX
@@ -0,0 +1,72 @@
1
+ Warming up --------------------------------------
2
+ benchmark:XXX XXX i/100ms
3
+ clamp_a1 XXX i/100ms
4
+ benchmark:XXX XXX i/100ms
5
+ clamp_a1 XXX i/100ms
6
+ clamp_b1 XXX i/100ms
7
+ benchmark:XXX XXX i/100ms
8
+ clamp_a3 XXX i/100ms
9
+ clamp_b3 XXX i/100ms
10
+ benchmark:XXX XXX i/100ms
11
+ clamp_a4 XXX i/100ms
12
+ clamp_b4 XXX i/100ms
13
+ benchmark:XXX XXX i/100ms
14
+ clamp_a1 XXX i/100ms
15
+ benchmark:XXX XXX i/100ms
16
+ clamp_a1 XXX i/100ms
17
+ clamp_b1 XXX i/100ms
18
+ benchmark:XXX XXX i/100ms
19
+ clamp_a3 XXX i/100ms
20
+ clamp_b3 XXX i/100ms
21
+ benchmark:XXX XXX i/100ms
22
+ clamp_a4 XXX i/100ms
23
+ clamp_b4 XXX i/100ms
24
+ benchmark:XXX XXX i/100ms
25
+ clamp_a1 XXX i/100ms
26
+ benchmark:XXX XXX i/100ms
27
+ clamp_a1 XXX i/100ms
28
+ clamp_b1 XXX i/100ms
29
+ benchmark:XXX XXX i/100ms
30
+ clamp_a3 XXX i/100ms
31
+ clamp_b3 XXX i/100ms
32
+ benchmark:XXX XXX i/100ms
33
+ clamp_a4 XXX i/100ms
34
+ clamp_b4 XXX i/100ms
35
+ Calculating -------------------------------------
36
+ benchmark:XXX XXX (XXX%) i/s - XXX
37
+ clamp_a1 XXX (XXX%) i/s - XXX
38
+ benchmark:XXX XXX (XXX%) i/s - XXX
39
+ clamp_a1 XXX (XXX%) i/s - XXX
40
+ clamp_b1 XXX (XXX%) i/s - XXX
41
+ benchmark:XXX XXX (XXX%) i/s - XXX
42
+ clamp_a3 XXX (XXX%) i/s - XXX
43
+ clamp_b3 XXX (XXX%) i/s - XXX
44
+ benchmark:XXX XXX (XXX%) i/s - XXX
45
+ clamp_a4 XXX (XXX%) i/s - XXX
46
+ clamp_b4 XXX (XXX%) i/s - XXX
47
+ benchmark:XXX XXX (XXX%) i/s - XXX
48
+ clamp_a1 XXX (XXX%) i/s - XXX
49
+ benchmark:XXX XXX (XXX%) i/s - XXX
50
+ clamp_a1 XXX (XXX%) i/s - XXX
51
+ clamp_b1 XXX (XXX%) i/s - XXX
52
+ benchmark:XXX XXX (XXX%) i/s - XXX
53
+ clamp_a3 XXX (XXX%) i/s - XXX
54
+ clamp_b3 XXX (XXX%) i/s - XXX
55
+ benchmark:XXX XXX (XXX%) i/s - XXX
56
+ clamp_a4 XXX (XXX%) i/s - XXX
57
+ clamp_b4 XXX (XXX%) i/s - XXX
58
+ benchmark:XXX XXX (XXX%) i/s - XXX
59
+ clamp_a1 XXX (XXX%) i/s - XXX
60
+ benchmark:XXX XXX (XXX%) i/s - XXX
61
+ clamp_a1 XXX (XXX%) i/s - XXX
62
+ clamp_b1 XXX (XXX%) i/s - XXX
63
+ benchmark:XXX XXX (XXX%) i/s - XXX
64
+ clamp_a3 XXX (XXX%) i/s - XXX
65
+ clamp_b3 XXX (XXX%) i/s - XXX
66
+ benchmark:XXX XXX (XXX%) i/s - XXX
67
+ clamp_a4 XXX (XXX%) i/s - XXX
68
+ clamp_b4 XXX (XXX%) i/s - XXX
69
+
70
+ Comparison:
71
+ XXX
72
+
@@ -0,0 +1,12 @@
1
+ user system total real
2
+ benchmark:XXX XXX XXX XXX (XXX)
3
+ clamp_a1 XXX XXX XXX (XXX)
4
+ benchmark:XXX XXX XXX XXX (XXX)
5
+ clamp_a1 XXX XXX XXX (XXX)
6
+ clamp_b1 XXX XXX XXX (XXX)
7
+ benchmark:XXX XXX XXX XXX (XXX)
8
+ clamp_a3 XXX XXX XXX (XXX)
9
+ clamp_b3 XXX XXX XXX (XXX)
10
+ benchmark:XXX XXX XXX XXX (XXX)
11
+ clamp_a4 XXX XXX XXX (XXX)
12
+ clamp_b4 XXX XXX XXX (XXX)
@@ -0,0 +1,12 @@
1
+ user system total real
2
+ benchmark:XXX XXX XXX XXX (XXX)
3
+ clamp_a1 XXX XXX XXX (XXX)
4
+ benchmark:XXX XXX XXX XXX (XXX)
5
+ clamp_a1 XXX XXX XXX (XXX)
6
+ clamp_b1 XXX XXX XXX (XXX)
7
+ benchmark:XXX XXX XXX XXX (XXX)
8
+ clamp_a3 XXX XXX XXX (XXX)
9
+ clamp_b3 XXX XXX XXX (XXX)
10
+ benchmark:XXX XXX XXX XXX (XXX)
11
+ clamp_a4 XXX XXX XXX (XXX)
12
+ clamp_b4 XXX XXX XXX (XXX)
@@ -0,0 +1,22 @@
1
+ benchmark:XXX
2
+ XXX
3
+ clamp_a1
4
+ XXX
5
+ benchmark:XXX
6
+ XXX
7
+ clamp_a1
8
+ XXX
9
+ clamp_b1
10
+ XXX
11
+ benchmark:XXX
12
+ XXX
13
+ clamp_a3
14
+ XXX
15
+ clamp_b3
16
+ XXX
17
+ benchmark:XXX
18
+ XXX
19
+ clamp_a4
20
+ XXX
21
+ clamp_b4
22
+ XXX
@@ -0,0 +1,2 @@
1
+ This benchmark set contains blocks that want a number of iterations - running all iterations XXX times
2
+ These are long benchmarks - we're increasing warmup and sample time
@@ -0,0 +1,7 @@
1
+ This benchmark set contains blocks that want a number of iterations - running all iterations XXX times
2
+ user system total real
3
+ bips:XXX XXX XXX XXX (XXX)
4
+ clamp_a1 XXX XXX XXX (XXX)
5
+ clamp_b1 XXX XXX XXX (XXX)
6
+ clamp_a2 XXX XXX XXX (XXX)
7
+ clamp_a3 XXX XXX XXX (XXX)
@@ -0,0 +1,7 @@
1
+ This benchmark set contains blocks that want a number of iterations - running all iterations XXX times
2
+ user system total real
3
+ bips:XXX XXX XXX XXX (XXX)
4
+ clamp_a1 XXX XXX XXX (XXX)
5
+ clamp_b1 XXX XXX XXX (XXX)
6
+ clamp_a2 XXX XXX XXX (XXX)
7
+ clamp_a3 XXX XXX XXX (XXX)
@@ -0,0 +1,11 @@
1
+ This benchmark set contains blocks that want a number of iterations - running all iterations XXX times
2
+ bips:XXX
3
+ XXX
4
+ clamp_a1
5
+ XXX
6
+ clamp_b1
7
+ XXX
8
+ clamp_a2
9
+ XXX
10
+ clamp_a3
11
+ XXX
@@ -0,0 +1,24 @@
1
+ Warming up --------------------------------------
2
+ interface:XXX XXX i/100ms
3
+ clamp_a XXX i/100ms
4
+ clamp_b XXX i/100ms
5
+ interface:XXX XXX i/100ms
6
+ clamp_a XXX i/100ms
7
+ clamp_b XXX i/100ms
8
+ interface:XXX XXX i/100ms
9
+ clamp_a XXX i/100ms
10
+ clamp_b XXX i/100ms
11
+ Calculating -------------------------------------
12
+ interface:XXX XXX (XXX%) i/s - XXX
13
+ clamp_a XXX (XXX%) i/s - XXX
14
+ clamp_b XXX (XXX%) i/s - XXX
15
+ interface:XXX XXX (XXX%) i/s - XXX
16
+ clamp_a XXX (XXX%) i/s - XXX
17
+ clamp_b XXX (XXX%) i/s - XXX
18
+ interface:XXX XXX (XXX%) i/s - XXX
19
+ clamp_a XXX (XXX%) i/s - XXX
20
+ clamp_b XXX (XXX%) i/s - XXX
21
+
22
+ Comparison:
23
+ XXX
24
+
@@ -0,0 +1,4 @@
1
+ user system total real
2
+ interface:XXX XXX XXX XXX (XXX)
3
+ clamp_a XXX XXX XXX (XXX)
4
+ clamp_b XXX XXX XXX (XXX)
@@ -0,0 +1,4 @@
1
+ user system total real
2
+ interface:XXX XXX XXX XXX (XXX)
3
+ clamp_a XXX XXX XXX (XXX)
4
+ clamp_b XXX XXX XXX (XXX)
@@ -0,0 +1,6 @@
1
+ interface:XXX
2
+ XXX
3
+ clamp_a
4
+ XXX
5
+ clamp_b
6
+ XXX
@@ -0,0 +1,9 @@
1
+ These are long benchmarks - we're increasing warmup and sample time
2
+ Warming up --------------------------------------
3
+ sleep XXX i/100ms
4
+ sleep XXX i/100ms
5
+ sleep XXX i/100ms
6
+ Calculating -------------------------------------
7
+ sleep XXX (XXX%) i/s - XXX
8
+ sleep XXX (XXX%) i/s - XXX
9
+ sleep XXX (XXX%) i/s - XXX
@@ -0,0 +1,2 @@
1
+ user system total real
2
+ sleep XXX XXX XXX (XXX)
@@ -0,0 +1,2 @@
1
+ user system total real
2
+ sleep XXX XXX XXX (XXX)
@@ -0,0 +1,2 @@
1
+ sleep
2
+ XXX
@@ -0,0 +1,9 @@
1
+ These are long benchmarks - we're increasing warmup and sample time
2
+ Warming up --------------------------------------
3
+ mri XXX i/100ms
4
+ mri XXX i/100ms
5
+ mri XXX i/100ms
6
+ Calculating -------------------------------------
7
+ mri XXX (XXX%) i/s - XXX
8
+ mri XXX (XXX%) i/s - XXX
9
+ mri XXX (XXX%) i/s - XXX