benchmark-ipsa 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a0b0ddb837469148fca997e25bdbf30574bb678
4
+ data.tar.gz: ef2786add7c3ceef93f31460f0e903d69f9e7740
5
+ SHA512:
6
+ metadata.gz: 2e317d5e6bbcd2c7f321b04c5d5be4fd157215db92cbfe5fcab9fb2ab7c8933c7e392d01b569bfbe9c293c9ee56d22b1acb94935b0adcdb61b6953f1afcb35c3
7
+ data.tar.gz: b9bb7c90da2705cf64cb5ad69f71a6cb590c6cba8659f7f487fa0a9fcf4b75dbf148ce2c58bef4ab5a2dc9d06eeca3611e273bfdb118ed35259f7fbc47b0872b
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.2.0
5
+ - 2.3.0
6
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in benchmark-ipsa.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dotan Nahum
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.
@@ -0,0 +1,75 @@
1
+ # benchmark-ipsa
2
+
3
+ [![Build Status](https://travis-ci.org/jondot/benchmark-ipsa.svg?branch=master)](https://travis-ci.org/jondot/benchmark-ipsa.svg)
4
+ [![Coverage Status](https://coveralls.io/repos/github/jondot/benchmark-ipsa/badge.svg?branch=master)](https://coveralls.io/github/jondot/benchmark-ipsa?branch=master)
5
+
6
+ A iterations per second enhancement to Benchmark that includes memory allocations,
7
+ based on [benchmark-ips](https://github.com/evanphx/benchmark-ips/).
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'benchmark-ipsa'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install benchmark-ipsa
25
+
26
+ ## Usage
27
+
28
+ ```ruby
29
+ require 'benchmark/ipsa'
30
+ Benchmark.ipsa do |x|
31
+ x.report('foo 1'){
32
+ arr = ['1', 2]
33
+ sleep 0.1
34
+ }
35
+ x.report('foo 2'){
36
+ sleep 0.1
37
+ }
38
+ end
39
+ ```
40
+
41
+ Results:
42
+
43
+ ```
44
+ Allocations -------------------------------------
45
+ foo 1 2/0 alloc/ret 1/0 strings/ret
46
+ foo 2 0/0 alloc/ret 0/0 strings/ret
47
+ Warming up --------------------------------------
48
+ foo 1 1.000 i/100ms
49
+ foo 2 1.000 i/100ms
50
+ Calculating -------------------------------------
51
+ foo 1 9.675 (± 0.0%) i/s - 49.000
52
+ foo 2 9.585 (± 0.0%) i/s - 48.000
53
+ ```
54
+
55
+
56
+ You can run the specs in this repo to see it live.
57
+
58
+ For more, see [benchmark-ips](https://github.com/evanphx/benchmark-ips/)
59
+
60
+ ## Development
61
+
62
+ Running the specs:
63
+
64
+ * `git clone`
65
+ * `bundle install`
66
+ * `bundle exec rake spec`
67
+
68
+ # Contributing
69
+
70
+ Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).
71
+
72
+ # Copyright
73
+
74
+ Copyright (c) 2016 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot). See [LICENSE](LICENSE.txt) for further details.
75
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:spec) do |t|
5
+ t.libs << "spec"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'benchmark/ipsa/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "benchmark-ipsa"
8
+ spec.version = Benchmark::Ipsa::VERSION
9
+ spec.authors = ["Dotan Nahum"]
10
+ spec.email = ["jondotan@gmail.com"]
11
+
12
+ spec.summary = %q{Benchmark IPS with allocations}
13
+ spec.description = %q{Benchmark IPS with allocations}
14
+ spec.homepage = "https://github.com/jondot/benchmark-ips"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'benchmark-ips', '~> 2.5.0'
23
+ spec.add_dependency 'memory_profiler', '~> 0.9.6'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.11'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'minitest', '~> 5.0'
28
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "benchmark/ipsa"
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
@@ -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,39 @@
1
+ require "benchmark/ipsa/version"
2
+ require 'memory_profiler'
3
+
4
+ module Benchmark
5
+ module Ipsa
6
+ def ipsa(*args, &block)
7
+ Benchmark.ips(*args){ |x|
8
+ block.call(x)
9
+ allocations(x)
10
+ }
11
+
12
+ end
13
+
14
+ def allocations(x)
15
+ return unless RUBY_VERSION >= "2.1.0" # MemoryProfiler needs 2.1. degrade to just ips
16
+
17
+ puts "Allocations -------------------------------------"
18
+ x.list.each do |entry|
19
+ report = MemoryProfiler.report(&entry.action)
20
+ $stdout.print(rjust(entry.label))
21
+ $stdout.printf("%10s alloc/ret %10s strings/ret\n",
22
+ "#{report.total_allocated}/#{report.total_retained}",
23
+ "#{report.strings_allocated.count}/#{report.strings_retained.count}")
24
+ end
25
+ end
26
+
27
+ def rjust(label) #stolen from benchmark-ips
28
+ label = label.to_s
29
+ if label.size > 20
30
+ "#{label}\n#{' ' * 20}"
31
+ else
32
+ label.rjust(20)
33
+ end
34
+ end
35
+
36
+ # Your code goes here...
37
+ end
38
+ extend Ipsa
39
+ end
@@ -0,0 +1,5 @@
1
+ module Benchmark
2
+ module Ipsa
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: benchmark-ipsa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dotan Nahum
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: benchmark-ips
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.5.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: memory_profiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.6
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.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
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
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ description: Benchmark IPS with allocations
84
+ email:
85
+ - jondotan@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - benchmark-ipsa.gemspec
97
+ - bin/console
98
+ - bin/setup
99
+ - lib/benchmark/ipsa.rb
100
+ - lib/benchmark/ipsa/version.rb
101
+ homepage: https://github.com/jondot/benchmark-ips
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.5.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Benchmark IPS with allocations
125
+ test_files: []