benchpress 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +10 -0
- data/Rakefile +1 -0
- data/benchpress.gemspec +24 -0
- data/lib/benchpress.rb +11 -0
- data/lib/benchpress/chart.rb +47 -0
- data/lib/benchpress/entity.rb +14 -0
- data/lib/benchpress/themes.rb +15 -0
- data/lib/benchpress/version.rb +3 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9528aae3490907cc35b0cdf0ea6386495b6b422e
|
4
|
+
data.tar.gz: 9996fddc495f27ef2e07465899324104a6fd9296
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f889f17220a46a3ce1bf4affd855984335f7ac5337fb012254468eee0331bbc2d25bf45bb1356af1f976f2bfe61bed7c03caa3dfee745cb1c5cf533e4802d9de
|
7
|
+
data.tar.gz: f9b4ba4793df4fb12d4b26ccc4e1bf5f9bc174e1b67a37a0dc8f510e1063b276e34db3e27646fdb5516f3c034d3705090c8c35a226af3d561b3407b42a51d842
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Brandon Weaver
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Benchpress
|
2
|
+
==========
|
3
|
+
|
4
|
+
Pit a few ruby methods against eachother, and chart it for great glory
|
5
|
+
|
6
|
+
Fair warning, this is super alpha one hour quick hack type material here. I intend to make it prettier later among other things, but I find it at least partially useful at this stage.
|
7
|
+
|
8
|
+
Props to the folks at Gruff (https://github.com/topfunky/gruff) for making this simpler to do, and to the Ruby team behind Benchmark.
|
9
|
+
|
10
|
+

|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/benchpress.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'benchpress/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "benchpress"
|
8
|
+
spec.version = Benchpress::VERSION
|
9
|
+
spec.authors = ["Brandon Weaver"]
|
10
|
+
spec.email = ["keystonelemur@gmail.com"]
|
11
|
+
spec.description = %q{Pit Ruby methods against eachother in benchmark, and chart for great glory}
|
12
|
+
spec.summary = %q{Ruby Benchmark + Gruff to auto-gen charts}
|
13
|
+
spec.homepage = "https://github.com/baweaver/Benchpress"
|
14
|
+
spec.license = "BSD"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "gruff"
|
24
|
+
end
|
data/lib/benchpress.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Benchpress
|
2
|
+
class Chart
|
3
|
+
# step - increment
|
4
|
+
# min - minimum # of profiles to run
|
5
|
+
# max - maximum # of profiles to run
|
6
|
+
# entities - data methods to run against
|
7
|
+
def initialize(opts = {})
|
8
|
+
@step = opts[:step] || 1
|
9
|
+
@min = opts[:min] || 0
|
10
|
+
@max = opts[:max] || 1000
|
11
|
+
@entities = opts[:entities]
|
12
|
+
@name = opts[:name] || "#{Time.now.strftime '%Y-%m-%d-%H:%M:%S'}"
|
13
|
+
@format = opts[:format] || 'png'
|
14
|
+
@theme = opts[:theme] || Gruff::Themes::THIRTYSEVEN_SIGNALS
|
15
|
+
end
|
16
|
+
|
17
|
+
def image_name
|
18
|
+
@name + '.' + @format
|
19
|
+
end
|
20
|
+
|
21
|
+
def step_points
|
22
|
+
@step_points ||= (@min..@max).select { |i| i % @step == 0 }
|
23
|
+
end
|
24
|
+
|
25
|
+
def calculate_data_points
|
26
|
+
@entities.each do |entity|
|
27
|
+
step_points.each do |n|
|
28
|
+
entity.data_points << Benchmark.measure { n.times { entity.method.call } }.real
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def render
|
34
|
+
calculate_data_points
|
35
|
+
|
36
|
+
Gruff::Line.new.tap { |g|
|
37
|
+
g.labels = step_points.each_with_index.reduce({}) { |hash, (val, index)|
|
38
|
+
index.odd? ? hash : hash.merge!({ index => val.to_s })
|
39
|
+
}
|
40
|
+
g.theme = @theme
|
41
|
+
@entities.each { |entity| g.data entity.name.to_sym, entity.data_points }
|
42
|
+
g.x_axis_label = 'Times (n)'
|
43
|
+
g.y_axis_label = 'Length (seconds)'
|
44
|
+
}.write image_name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Benchpress
|
2
|
+
class Entity
|
3
|
+
attr_reader :method, :name
|
4
|
+
attr_accessor :data_points
|
5
|
+
|
6
|
+
# color - line color
|
7
|
+
# method - what are we benchmarking?
|
8
|
+
def initialize(opts = {})
|
9
|
+
@method = opts[:method]
|
10
|
+
@name = opts[:name] || ''
|
11
|
+
@data_points = []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Various Themes for Benchpress. Also look into Gruff themes.
|
2
|
+
# https://github.com/topfunky/gruff/blob/master/lib/gruff/themes.rb
|
3
|
+
|
4
|
+
module Benchpress
|
5
|
+
class Themes
|
6
|
+
|
7
|
+
# Simple light background with Primary colors.
|
8
|
+
PLAIN = {
|
9
|
+
background_colors: %w(#ff0000 #00ff00),
|
10
|
+
background_direction: :top_bottom,
|
11
|
+
colors: %w(#ff0000 #00ff00 #0000ff #fff000 #000fff #ffff00 #00ffff #ff00ff),
|
12
|
+
marker_color: '#000000'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: benchpress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Weaver
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: gruff
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Pit Ruby methods against eachother in benchmark, and chart for great
|
56
|
+
glory
|
57
|
+
email:
|
58
|
+
- keystonelemur@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- benchpress.gemspec
|
69
|
+
- lib/benchpress.rb
|
70
|
+
- lib/benchpress/chart.rb
|
71
|
+
- lib/benchpress/entity.rb
|
72
|
+
- lib/benchpress/themes.rb
|
73
|
+
- lib/benchpress/version.rb
|
74
|
+
homepage: https://github.com/baweaver/Benchpress
|
75
|
+
licenses:
|
76
|
+
- BSD
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.1.10
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Ruby Benchmark + Gruff to auto-gen charts
|
98
|
+
test_files: []
|