benchmark_driver-output-gruff 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6506f21ed00de9d99ab12ff20a64bcd023f8c4c30deab926a8c75dbf68e3cf37
4
+ data.tar.gz: 557150da97ddba481564321532adf0dbf7fbf1af44d3123cbaeedf6e248f08df
5
+ SHA512:
6
+ metadata.gz: bf0dcbe0eb309e35420236898494768432452e7845cc86741064c8588e2d4ef5ab33f1e396fca3fb769141da06f8590e82460202ab9b83121f7cc0bcdc12e704
7
+ data.tar.gz: 7e1071081cfbb4a300fbffb9241d2b2b2581b0140024c4826808c9f4421cebd95ee10f1981c5c24b908f5c4df13523388d3869fb8791b8d54adb4a1dc9f9a203
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
10
+ graph.png
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # v0.1.0
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in benchmark_driver-output-gruff.gemspec
6
+ gemspec
7
+
8
+ # gem 'benchmark_driver', path: '/Users/k0kubun/src/github.com/k0kubun/benchmark_driver'
9
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Takashi Kokubun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # BenchmarkDriver::Output::Gruff
2
+
3
+ benchmark\_driver plugin to render graph using gruff.gem.
4
+
5
+ ## Installation
6
+
7
+ Install rmagick.gem's dependency. See also: https://github.com/rmagick/rmagick
8
+
9
+ ```bash
10
+ # macOS
11
+ brew install imagemagick@6
12
+ PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick
13
+
14
+ # Ubuntu
15
+ sudo apt-get install libmagickwand-dev
16
+ ```
17
+
18
+ And install the following gem.
19
+
20
+ ```ruby
21
+ gem 'benchmark_driver-output-gruff'
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "benchmark_driver/output/gruff/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "benchmark_driver-output-gruff"
8
+ spec.version = BenchmarkDriver::Output::Gruff::VERSION
9
+ spec.authors = ["Takashi Kokubun"]
10
+ spec.email = ["takashikkbn@gmail.com"]
11
+
12
+ spec.summary = %q{Show graph on benchmark_driver using gruff.gem}
13
+ spec.description = %q{Show graph on benchmark_driver using gruff.gem}
14
+ spec.homepage = "https://github.com/benchmark-driver/benchmark_driver-output-gruff"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "benchmark_driver", ">= 0.10.12"
25
+ spec.add_dependency "gruff"
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "benchmark_driver/output/gruff"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ prelude: |
2
+ class Array
3
+ alias_method :blank?, :empty?
4
+ end
5
+ array = []
6
+ benchmark:
7
+ empty: array.empty?
8
+ blank: array.blank?
9
+ loop_count: 10000000
@@ -0,0 +1,8 @@
1
+ prelude: |
2
+ class Array
3
+ alias_method :blank?, :empty?
4
+ end
5
+ array = []
6
+ benchmark:
7
+ blank: array.blank?
8
+ loop_count: 10000000
@@ -0,0 +1,71 @@
1
+ require 'gruff'
2
+ require 'benchmark_driver/output/gruff/version'
3
+
4
+ class BenchmarkDriver::Output::Gruff
5
+ GRAPH_PATH = 'graph.png'
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
22
+ end
23
+
24
+ def with_benchmark(&block)
25
+ @with_benchmark = true
26
+ puts "running benchmark..."
27
+ result = block.call
28
+
29
+ print "rendering graph..."
30
+ g = Gruff::SideBar.new
31
+ g.theme = {
32
+ colors: ['#3285e1', '#489d32', '#e2c13e', '#12a702', '#aedaa9'],
33
+ marker_color: '#dddddd',
34
+ font_color: 'black',
35
+ background_colors: 'white'
36
+ }
37
+ g.x_axis_label = @metrics_type.unit
38
+ g.minimum_value = 0
39
+ g.maximum_value = (@value_by_exec_by_job.values.map(&:values).flatten.max * 1.2).to_i
40
+ if @value_by_exec_by_job.keys.size == 1
41
+ # Use Ruby version for base axis
42
+ job = @value_by_exec_by_job.keys.first
43
+ g.labels = Hash[@executables.map.with_index { |exec, index| [index, exec.name] } ]
44
+ g.data job, @executables.map { |exec| @value_by_exec_by_job[job][exec.name] }
45
+ else
46
+ # Use benchmark name for base axis, use different colors for different Ruby versions
47
+ jobs = @value_by_exec_by_job.keys
48
+ g.labels = Hash[jobs.map.with_index { |job, index| [index, job] }]
49
+ @executables.each do |executable|
50
+ g.data executable.description, jobs.map { |job| @value_by_exec_by_job[job][executable.name] }
51
+ end
52
+ end
53
+ g.bar_spacing = 0.6
54
+ g.write(GRAPH_PATH)
55
+ puts ": #{GRAPH_PATH}"
56
+
57
+ result
58
+ end
59
+
60
+ def with_job(job, &block)
61
+ @job = job
62
+ block.call
63
+ end
64
+
65
+ # @param [BenchmarkDriver::Metrics] metrics
66
+ def report(metrics)
67
+ if @with_benchmark
68
+ @value_by_exec_by_job[@job.name][metrics.executable.name] = metrics.value
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,7 @@
1
+ module BenchmarkDriver
2
+ module Output
3
+ class Gruff
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: benchmark_driver-output-gruff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Takashi Kokubun
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: benchmark_driver
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.12
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.12
27
+ - !ruby/object:Gem::Dependency
28
+ name: gruff
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Show graph on benchmark_driver using gruff.gem
70
+ email:
71
+ - takashikkbn@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - CHANGELOG.md
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - benchmark_driver-output-gruff.gemspec
83
+ - bin/console
84
+ - bin/setup
85
+ - examples/multi.yml
86
+ - examples/single.yml
87
+ - lib/benchmark_driver/output/gruff.rb
88
+ - lib/benchmark_driver/output/gruff/version.rb
89
+ homepage: https://github.com/benchmark-driver/benchmark_driver-output-gruff
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.7.3
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Show graph on benchmark_driver using gruff.gem
113
+ test_files: []