bixby-bench 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +55 -0
- data/LICENSE.txt +20 -0
- data/README.md +38 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/bixby-bench.gemspec +62 -0
- data/lib/bixby-bench.rb +2 -0
- data/lib/bixby/bench.rb +87 -0
- data/lib/bixby/bench/divider.rb +10 -0
- data/lib/bixby/bench/report.rb +19 -0
- data/lib/bixby/bench/sample.rb +32 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ddb5ddd19287c016ab80556daecb287bbb89bfe9
|
4
|
+
data.tar.gz: c872f84980204c7f93c3b7af836427486c07edbf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f48055b85cc14e416c590fc3d73795b9538816f499c6180af1d47f28ca15f81ac9cdd389a8740d34afbacb1f6a863d121377e8c0040e2e89d8a98d9b15004f97
|
7
|
+
data.tar.gz: d997e91901da5e10556b90c5a325df1fde6c805d13109601676be5435bf3a7c349b2999b046edc5ab6b67826d208ee11083c52e43dca753517e1b35a791e0ebe
|
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.6)
|
5
|
+
allocation_stats (0.1.5)
|
6
|
+
builder (3.2.2)
|
7
|
+
descendants_tracker (0.0.4)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
9
|
+
faraday (0.9.0)
|
10
|
+
multipart-post (>= 1.2, < 3)
|
11
|
+
git (1.2.8)
|
12
|
+
github_api (0.12.2)
|
13
|
+
addressable (~> 2.3)
|
14
|
+
descendants_tracker (~> 0.0.4)
|
15
|
+
faraday (~> 0.8, < 0.10)
|
16
|
+
hashie (>= 3.3)
|
17
|
+
multi_json (>= 1.7.5, < 2.0)
|
18
|
+
nokogiri (~> 1.6.3)
|
19
|
+
oauth2
|
20
|
+
hashie (3.3.1)
|
21
|
+
highline (1.6.21)
|
22
|
+
jeweler (2.0.1)
|
23
|
+
builder
|
24
|
+
bundler (>= 1.0)
|
25
|
+
git (>= 1.2.5)
|
26
|
+
github_api
|
27
|
+
highline (>= 1.6.15)
|
28
|
+
nokogiri (>= 1.5.10)
|
29
|
+
rake
|
30
|
+
jwt (1.0.0)
|
31
|
+
mini_portile (0.6.0)
|
32
|
+
multi_json (1.10.1)
|
33
|
+
multi_xml (0.5.5)
|
34
|
+
multipart-post (2.0.0)
|
35
|
+
nokogiri (1.6.3.1)
|
36
|
+
mini_portile (= 0.6.0)
|
37
|
+
oauth2 (1.0.0)
|
38
|
+
faraday (>= 0.8, < 0.10)
|
39
|
+
jwt (~> 1.0)
|
40
|
+
multi_json (~> 1.3)
|
41
|
+
multi_xml (~> 0.5)
|
42
|
+
rack (~> 1.2)
|
43
|
+
rack (1.5.2)
|
44
|
+
rake (10.3.2)
|
45
|
+
thread_safe (0.3.4)
|
46
|
+
yard (0.8.7.4)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
allocation_stats
|
53
|
+
bundler (~> 1.0)
|
54
|
+
jeweler (~> 2.0.1)
|
55
|
+
yard (~> 0.7)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Chetan Sarva
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# bixby-bench
|
2
|
+
|
3
|
+
A simple wrapper around the stdlib Benchmark with allocation tracing mixed in
|
4
|
+
|
5
|
+
## Installation and Usage
|
6
|
+
|
7
|
+
```bash
|
8
|
+
gem install bixby-bench
|
9
|
+
```
|
10
|
+
|
11
|
+
Usage is very similar to `Benchmark.bm`:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
Bixby::Bench.run(10_000) do |b| # 10,000 = number of sample runs
|
15
|
+
b.sample('test_method') do
|
16
|
+
Test.method()
|
17
|
+
end
|
18
|
+
b.divider
|
19
|
+
b.sample('test_method2') do
|
20
|
+
Test.method2()
|
21
|
+
end
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
## Contributing to bixby-bench
|
26
|
+
|
27
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
28
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
29
|
+
* Fork the project.
|
30
|
+
* Start a feature/bugfix branch.
|
31
|
+
* Commit and push until you are happy with your contribution.
|
32
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
33
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
34
|
+
|
35
|
+
## Copyright
|
36
|
+
|
37
|
+
Copyright (c) 2014 Chetan Sarva. See LICENSE.txt for
|
38
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "bixby-bench"
|
18
|
+
gem.homepage = "http://github.com/chetan/bixby-bench"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Benchmarking utilities}
|
21
|
+
gem.description = %Q{Simple benchmarking utilities that just work, right out of the box}
|
22
|
+
gem.email = "chetan@pixelcop.net"
|
23
|
+
gem.authors = ["Chetan Sarva"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['test'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'yard'
|
44
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bixby-bench.gemspec
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: bixby-bench 0.1.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "bixby-bench"
|
9
|
+
s.version = "0.1.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Chetan Sarva"]
|
14
|
+
s.date = "2014-11-07"
|
15
|
+
s.description = "Simple benchmarking utilities that just work, right out of the box"
|
16
|
+
s.email = "chetan@pixelcop.net"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bixby-bench.gemspec",
|
30
|
+
"lib/bixby-bench.rb",
|
31
|
+
"lib/bixby/bench.rb",
|
32
|
+
"lib/bixby/bench/divider.rb",
|
33
|
+
"lib/bixby/bench/report.rb",
|
34
|
+
"lib/bixby/bench/sample.rb"
|
35
|
+
]
|
36
|
+
s.homepage = "http://github.com/chetan/bixby-bench"
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.rubygems_version = "2.4.2"
|
39
|
+
s.summary = "Benchmarking utilities"
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 4
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<allocation_stats>, [">= 0"])
|
46
|
+
s.add_development_dependency(%q<yard>, ["~> 0.7"])
|
47
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
48
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<allocation_stats>, [">= 0"])
|
51
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
52
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<allocation_stats>, [">= 0"])
|
57
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
data/lib/bixby-bench.rb
ADDED
data/lib/bixby/bench.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
|
2
|
+
require "benchmark"
|
3
|
+
require "allocation_stats"
|
4
|
+
|
5
|
+
require "bixby/bench/divider"
|
6
|
+
require "bixby/bench/sample"
|
7
|
+
require "bixby/bench/report"
|
8
|
+
|
9
|
+
module Bixby
|
10
|
+
class Bench
|
11
|
+
|
12
|
+
def self.run(sample_size, memory=true)
|
13
|
+
bench = Bench.new(sample_size, memory)
|
14
|
+
yield(bench)
|
15
|
+
|
16
|
+
# now that we have all samples, run the thing
|
17
|
+
sync_stdout { bench.run_all }
|
18
|
+
|
19
|
+
bench
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.sync_stdout
|
23
|
+
begin
|
24
|
+
old_sync = STDOUT.sync
|
25
|
+
STDOUT.sync = true
|
26
|
+
yield
|
27
|
+
ensure
|
28
|
+
STDOUT.sync = old_sync unless old_sync.nil?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(sample_size, memory=true)
|
33
|
+
@sample_size = sample_size
|
34
|
+
@memory = memory
|
35
|
+
@samples = []
|
36
|
+
end
|
37
|
+
|
38
|
+
def sample(label, &block)
|
39
|
+
@samples << Sample.new(label, block, @sample_size, @memory)
|
40
|
+
end
|
41
|
+
alias_method :report, :sample
|
42
|
+
|
43
|
+
def divider
|
44
|
+
@samples << Divider.new
|
45
|
+
end
|
46
|
+
alias_method :add_divider, :divider
|
47
|
+
|
48
|
+
def label_width
|
49
|
+
if !@label_width then
|
50
|
+
@label_width = @samples.find_all{ |s| Sample === s }.
|
51
|
+
max{ |a, b| a.label.length <=> b.label.length }.
|
52
|
+
label.length + 1
|
53
|
+
|
54
|
+
@label_width = 40 if @label_width < 40
|
55
|
+
end
|
56
|
+
|
57
|
+
return @label_width
|
58
|
+
end
|
59
|
+
|
60
|
+
def divider_width
|
61
|
+
@divider_width ||= (label_width + (@memory ? 75 : 45))
|
62
|
+
end
|
63
|
+
|
64
|
+
def print_header
|
65
|
+
caption = Benchmark::CAPTION
|
66
|
+
if @memory then
|
67
|
+
caption = caption.gsub(/\n$/, '') + " allocations memsize\n"
|
68
|
+
end
|
69
|
+
print ' '*label_width + caption
|
70
|
+
end
|
71
|
+
|
72
|
+
def run_all
|
73
|
+
print_header
|
74
|
+
|
75
|
+
@samples.each do |sample|
|
76
|
+
if Divider === sample then
|
77
|
+
sample.print(divider_width)
|
78
|
+
next
|
79
|
+
end
|
80
|
+
|
81
|
+
print sample.label.ljust(label_width)
|
82
|
+
sample.measure.print
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
module Bixby
|
3
|
+
class Bench
|
4
|
+
class Report
|
5
|
+
attr_accessor :tms, :allocation_stats
|
6
|
+
|
7
|
+
def print
|
8
|
+
if @allocation_stats then
|
9
|
+
format = Benchmark::FORMAT.gsub(/\n$/, '') + " %16d %12d\n"
|
10
|
+
allocations = allocation_stats.allocations.all.size
|
11
|
+
memsize = allocation_stats.allocations.bytes.to_a.inject(&:+)
|
12
|
+
puts @tms.format(format, allocations, memsize)
|
13
|
+
else
|
14
|
+
puts @tms
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
module Bixby
|
3
|
+
class Bench
|
4
|
+
class Sample
|
5
|
+
|
6
|
+
attr_reader :label, :block
|
7
|
+
|
8
|
+
def initialize(label, block, sample_size, memory)
|
9
|
+
@label = label
|
10
|
+
@block = block
|
11
|
+
@sample_size = sample_size
|
12
|
+
@memory = memory
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
@block.call
|
17
|
+
end
|
18
|
+
|
19
|
+
def measure
|
20
|
+
report = Report.new
|
21
|
+
report.tms = Benchmark.measure { @sample_size.times { self.call } }
|
22
|
+
|
23
|
+
if @memory then
|
24
|
+
report.allocation_stats = AllocationStats.new(burn: 5).trace { self.call }
|
25
|
+
end
|
26
|
+
|
27
|
+
return report
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bixby-bench
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chetan Sarva
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: allocation_stats
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.7'
|
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.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.1
|
69
|
+
description: Simple benchmarking utilities that just work, right out of the box
|
70
|
+
email: chetan@pixelcop.net
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files:
|
74
|
+
- LICENSE.txt
|
75
|
+
- README.md
|
76
|
+
files:
|
77
|
+
- ".document"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- VERSION
|
84
|
+
- bixby-bench.gemspec
|
85
|
+
- lib/bixby-bench.rb
|
86
|
+
- lib/bixby/bench.rb
|
87
|
+
- lib/bixby/bench/divider.rb
|
88
|
+
- lib/bixby/bench/report.rb
|
89
|
+
- lib/bixby/bench/sample.rb
|
90
|
+
homepage: http://github.com/chetan/bixby-bench
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Benchmarking utilities
|
114
|
+
test_files: []
|