benchmark_driver-output-rubybench 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a977f8e20db83f16767a4aecdb0fd396a98d2e6
4
+ data.tar.gz: ae279d4d48ee009a846ff9010a7c8ae4686f441b
5
+ SHA512:
6
+ metadata.gz: 93aee7f4e7653a61a3a88a440694ddaa24bf8694ba0531fc76f5dedfed41ccd7fe28d640b8ed774d4728fd825a1553eba3d9858fb0a31681666fb82aab9e9cf9
7
+ data.tar.gz: dec25a74a89cae38ada018f3bb85a678b20e5dcd69e4791e0084f5a2150674b6a8a0daaec17e820ed83f92f8640ed44fb2c3ab001ca5d9d93c6f1893470adf45
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
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-rubybench.gemspec
6
+ gemspec
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,7 @@
1
+ # BenchmarkDriver::Output::Rubybench
2
+
3
+ Use this with `gem install benchmark_driver-output-rubybench` on ruby-bench-docker.
4
+
5
+ ## License
6
+
7
+ 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,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "benchmark_driver/output/rubybench/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "benchmark_driver-output-rubybench"
8
+ spec.version = BenchmarkDriver::Output::Rubybench::VERSION
9
+ spec.authors = ["Takashi Kokubun"]
10
+ spec.email = ["takashikkbn@gmail.com"]
11
+
12
+ spec.summary = %q{benchmark_driver plugin to output result to RubyBench}
13
+ spec.description = %q{benchmark_driver plugin to output result to RubyBench}
14
+ spec.homepage = "https://github.com/ruby-bench/ruby-bench-suite"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "benchmark_driver", ">= 0.11"
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "benchmark_driver/output/rubybench"
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,74 @@
1
+ # This file is auto-loaded by `BenchmarkDriver::Output` when `-o rubybench` is specified.
2
+ require 'benchmark_driver'
3
+ require 'net/http'
4
+
5
+ # Common environment variables:
6
+ # API_URL=rubybench.org
7
+ # API_NAME
8
+ # API_PASSWORD
9
+ # RUBY_COMMIT_HASH or RUBY_VERSION
10
+ # Benchmark-specific environment variables:
11
+ # BENCHMARK_TYPE_SCRIPT_URL
12
+ # BENCHMARK_TYPE_DIGEST
13
+ # REPO_NAME
14
+ # ORGANIZATION_NAME
15
+ class BenchmarkDriver::Output::Rubybench < BenchmarkDriver::BulkOutput
16
+ # For maintainability, this doesn't support streaming progress output.
17
+ # @param [Hash{ BenchmarkDriver::Job => Hash{ BenchmarkDriver::Context => { BenchmarkDriver::Metric => Float } } }] result
18
+ # @param [Array<BenchmarkDriver::Metric>] metrics
19
+ def bulk_output(result:, metrics:)
20
+ metrics.each do |metric|
21
+ result.each do |job, context_metric_value|
22
+ context_value = {}
23
+ context_metric_value.each do |context, metric_value|
24
+ if metric_value.key?(metric)
25
+ context_value[context] = metric_value[metric]
26
+ end
27
+ end
28
+
29
+ create_benchmark_run(job, metric, context_value)
30
+ end
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ # Create BenchmarkRun record on RubyBench
37
+ # @param [BenchmarkDriver::Job] job
38
+ # @param [BenchmarkDriver::Metric] metric
39
+ # @param [Hash{ BenchmarkDriver::Context => Float }] context_value
40
+ def create_benchmark_run(job, metric, context_value)
41
+ http = Net::HTTP.new(ENV.fetch('API_URL', 'rubybench.org'), 443)
42
+ http.use_ssl = true
43
+ request = Net::HTTP::Post.new('/benchmark_runs')
44
+ request.basic_auth(ENV.fetch('API_NAME'), ENV.fetch('API_PASSWORD'))
45
+
46
+ initiator_hash = {}
47
+ if ENV.key?('RUBY_COMMIT_HASH')
48
+ initiator_hash['commit_hash'] = ENV['RUBY_COMMIT_HASH']
49
+ elsif ENV.key?('RUBY_VERSION')
50
+ initiator_hash['version'] = ENV['RUBY_VERSION']
51
+ end
52
+
53
+ result_hash = {}
54
+ context_value.each do |context, value|
55
+ initiator_hash["benchmark_run[result][#{context.name}]"] = value
56
+ end
57
+
58
+ context = context_value.keys.first
59
+ ruby_version = IO.popen([*context.executable.command, '-v'], &:read)
60
+
61
+ request.set_form_data({
62
+ 'benchmark_result_type[name]' => metric.name,
63
+ 'benchmark_result_type[unit]' => metric.unit,
64
+ 'benchmark_type[category]' => job.name,
65
+ 'benchmark_type[script_url]' => ENV.fetch('BENCHMARK_TYPE_SCRIPT_URL'),
66
+ 'benchmark_type[digest]' => ENV.fetch('BENCHMARK_TYPE_DIGEST'),
67
+ 'benchmark_run[environment]' => { 'Ruby version' => ruby_version }.merge(context.environment).to_yaml,
68
+ 'repo' => ENV.fetch('REPO_NAME'),
69
+ 'organization' => ENV.fetch('ORGANIZATION_NAME'),
70
+ }.merge(initiator_hash).merge(result_hash))
71
+
72
+ puts http.request(request).body
73
+ end
74
+ end
@@ -0,0 +1,7 @@
1
+ module BenchmarkDriver
2
+ module Output
3
+ class Rubybench
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: benchmark_driver-output-rubybench
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-07-01 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.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: benchmark_driver plugin to output result to RubyBench
56
+ email:
57
+ - takashikkbn@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - benchmark_driver-output-rubybench.gemspec
68
+ - bin/console
69
+ - bin/setup
70
+ - lib/benchmark_driver/output/rubybench.rb
71
+ - lib/benchmark_driver/output/rubybench/version.rb
72
+ homepage: https://github.com/ruby-bench/ruby-bench-suite
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.6.14.1
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: benchmark_driver plugin to output result to RubyBench
96
+ test_files: []