benchmark_driver-output-gruff 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 31e480d2abc76ab7a60e682717a65fc7ef432d56f5653f9deb63c92443f512d7
4
- data.tar.gz: d4ec744e162c8d7eac36b14d76a896111d307af219a2c835362b8b6ef2ce60e7
2
+ SHA1:
3
+ metadata.gz: 3ea4dd89d1d465b1d6c12e47132d2e3a5dd6e4d1
4
+ data.tar.gz: 4d7ebef3ee1718032b6c8de4f9e8d6a406232066
5
5
  SHA512:
6
- metadata.gz: c000c7e3f7941759dd5fe4fd2a373275a69539deb895cb6d49562df2fd246c967c502f1bd1bcf6c1735812f3f2ff36359b61cf681b7b0d94228891fa8d2fd804
7
- data.tar.gz: a3d800458a68e536aa598ca3eb32c3f21fda2bd631d7314284139158fc1b8ef78370d03377eaa7d4bd3001d974e76a96f4339e22b691822bcbb97fb132cb7dcf
6
+ metadata.gz: c48a3fe0653fb56f3ef914ef024984d99342b9bf3ca04e0a990e3e7d0d8edd4e8162c4e57da5bda47997bb4c87117d58f0d98815045f33a6cfd2372f0362d5cf
7
+ data.tar.gz: 6176005cf5c2b9b2c1947f2ca59e0fc6645e779c61567a6270c3eaf225127c1016d786f04553ca576f339b161e7b401d46534640c949bac6916cda00a283f218
data/README.md CHANGED
@@ -29,6 +29,15 @@ Specify `-o gruff`/`--output gruff`. Then `graph.png` will be created.
29
29
  bundle exec benchmark-driver examples/multi.yml -o gruff --rbenv '2.4.2;2.5.0'
30
30
  ```
31
31
 
32
+ ## Example
33
+ ### benchmark-driver/optcarrot
34
+
35
+ ![](./images/optcarrot.png)
36
+
37
+ ### benchmark-driver/mjit-benchmarks
38
+
39
+ ![](./images/mjit.png)
40
+
32
41
  ## License
33
42
 
34
43
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,11 +1,10 @@
1
1
 
2
2
  lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "benchmark_driver/output/gruff/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "benchmark_driver-output-gruff"
8
- spec.version = BenchmarkDriver::Output::Gruff::VERSION
7
+ spec.version = "0.2.0"
9
8
  spec.authors = ["Takashi Kokubun"]
10
9
  spec.email = ["takashikkbn@gmail.com"]
11
10
 
@@ -21,7 +20,7 @@ Gem::Specification.new do |spec|
21
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
21
  spec.require_paths = ["lib"]
23
22
 
24
- spec.add_dependency "benchmark_driver", ">= 0.10.12"
23
+ spec.add_dependency "benchmark_driver", ">= 0.11.1"
25
24
  spec.add_dependency "gruff"
26
25
  spec.add_development_dependency "bundler", "~> 1.16"
27
26
  spec.add_development_dependency "rake", "~> 10.0"
data/images/mjit.png ADDED
Binary file
Binary file
@@ -1,31 +1,18 @@
1
1
  require 'gruff'
2
- require 'benchmark_driver/output/gruff/version'
2
+ require 'benchmark_driver'
3
3
 
4
- class BenchmarkDriver::Output::Gruff
4
+ class BenchmarkDriver::Output::Gruff < BenchmarkDriver::BulkOutput
5
5
  GRAPH_PATH = 'graph.png'
6
6
 
7
- # @param [BenchmarkDriver::Metrics::Type] metrics_type
8
- attr_writer :metrics_type
9
-
10
- # @param [Array<BenchmarkDriver::*::Job>] jobs
11
- # @param [Array<BenchmarkDriver::Config::Executable>] executables
12
- def initialize(jobs:, executables:)
13
- @jobs = jobs
14
- @executables = executables
15
- @value_by_exec_by_job = Hash.new { |h, k| h[k] = {} }
16
- end
17
-
18
- def with_warmup(&block)
19
- # noop
20
- puts "warming up..."
21
- block.call
7
+ # @param [Array<String>] job_names
8
+ # @param [Array<String>] context_names
9
+ def initialize(job_names:, context_names:)
10
+ @context_names = context_names
22
11
  end
23
12
 
24
- def with_benchmark(&block)
25
- @with_benchmark = true
26
- puts "running benchmark..."
27
- result = block.call
28
-
13
+ # @param [Hash{ BenchmarkDriver::Job => Hash{ BenchmarkDriver::Context => { BenchmarkDriver::Metric => Float } } }] result
14
+ # @param [Array<BenchmarkDriver::Metric>] metrics
15
+ def bulk_output(result:, metrics:)
29
16
  print "rendering graph..."
30
17
  g = Gruff::SideBar.new
31
18
  g.theme = {
@@ -34,41 +21,41 @@ class BenchmarkDriver::Output::Gruff
34
21
  font_color: 'black',
35
22
  background_colors: 'white'
36
23
  }
37
- g.x_axis_label = @metrics_type.unit
24
+ metric = metrics.first # only one metric is supported for now
25
+ g.x_axis_label = metric.unit
38
26
  g.legend_font_size = 10.0
39
27
  g.marker_font_size = 14.0
40
28
  g.minimum_value = 0
41
- g.maximum_value = (@value_by_exec_by_job.values.map(&:values).flatten.max * 1.2).to_i
42
- if @value_by_exec_by_job.keys.size == 1
29
+ g.maximum_value = (result.values.map(&:values).flatten.map(&:values).flatten.max * 1.2).to_i
30
+ if result.keys.size == 1
43
31
  # Use Ruby version for base axis
44
- job = @value_by_exec_by_job.keys.first
45
- g.labels = Hash[@executables.map.with_index { |exec, index| [index, exec.name] } ]
46
- g.data job, @executables.map { |exec| @value_by_exec_by_job[job][exec.name] }
32
+ job = result.keys.first
33
+ g.labels = Hash[result[job].keys.map.with_index { |context, index| [index, context.name] } ]
34
+ g.data job.name, result[job].map { |_, metric_value| metric_value[metric] }
47
35
  else
48
36
  # Use benchmark name for base axis, use different colors for different Ruby versions
49
- jobs = @value_by_exec_by_job.keys
50
- g.labels = Hash[jobs.map.with_index { |job, index| [index, job] }]
51
- @executables.each do |executable|
52
- g.data executable.description, jobs.map { |job| @value_by_exec_by_job[job][executable.name] }
37
+ jobs = result.keys
38
+ g.labels = Hash[jobs.map.with_index { |job, index| [index, job.name] }]
39
+ @context_names.each do |context_name|
40
+ context = @result[jobs.first].keys.find { |c| c.name == context_name }
41
+ g.data context.executable.description, jobs.map { |job|
42
+ _, metric_value = @result[job].find { |context, _| context.name == context_name }
43
+ metric_value[metric]
44
+ }
53
45
  end
54
46
  end
55
47
  g.bar_spacing = 0.6
56
48
  g.write(GRAPH_PATH)
57
49
  puts ": #{GRAPH_PATH}"
58
-
59
- result
60
50
  end
61
51
 
62
52
  def with_job(job, &block)
63
53
  puts "* #{job.name}..."
64
- @job = job
65
- block.call
54
+ super
66
55
  end
67
56
 
68
- # @param [BenchmarkDriver::Metrics] metrics
69
- def report(metrics)
70
- if @with_benchmark
71
- @value_by_exec_by_job[@job.name][metrics.executable.name] = metrics.value
72
- end
57
+ def with_context(context, &block)
58
+ puts " * #{context.name}..."
59
+ super
73
60
  end
74
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_driver-output-gruff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-21 00:00:00.000000000 Z
11
+ date: 2018-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark_driver
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.12
19
+ version: 0.11.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.12
26
+ version: 0.11.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gruff
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,8 +84,9 @@ files:
84
84
  - bin/setup
85
85
  - examples/multi.yml
86
86
  - examples/single.yml
87
+ - images/mjit.png
88
+ - images/optcarrot.png
87
89
  - lib/benchmark_driver/output/gruff.rb
88
- - lib/benchmark_driver/output/gruff/version.rb
89
90
  homepage: https://github.com/benchmark-driver/benchmark_driver-output-gruff
90
91
  licenses:
91
92
  - MIT
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  version: '0'
107
108
  requirements: []
108
109
  rubyforge_project:
109
- rubygems_version: 2.7.3
110
+ rubygems_version: 2.6.14.1
110
111
  signing_key:
111
112
  specification_version: 4
112
113
  summary: Show graph on benchmark_driver using gruff.gem
@@ -1,7 +0,0 @@
1
- module BenchmarkDriver
2
- module Output
3
- class Gruff
4
- VERSION = "0.1.1"
5
- end
6
- end
7
- end