measuremerize 0.1.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 +9 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +56 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/measuremerize.rb +45 -0
- data/lib/measuremerize/version.rb +3 -0
- data/measuremerize.gemspec +24 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2563e97b9f4f375655c3883c196a64a38db97126
|
4
|
+
data.tar.gz: 3e51fd5d8986181e2748a256adbd4a1f0899c0ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0780a7ae960617ccbe0d06a2fb5b1cdd0446f1e48cccb2c009adb079283dba69cca26219bc90c3c6fff3b1b7dcb98a45b62a55bd922a93789e42175b41429f2e
|
7
|
+
data.tar.gz: 11c3956559cf8595d1f2ac6cda5483707f11f9c44b26ef4b01cacdbb26879946e399fd0f3977c9238f16aed9a856a05a3a8ff23a14ee0235296c0bf76e00eb7e
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Kristian Rasmussen
|
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,56 @@
|
|
1
|
+
# Measuremerize
|
2
|
+
|
3
|
+
This gem will help you optimize your ruby code, given that you surround your
|
4
|
+
colprit block with
|
5
|
+
|
6
|
+
```
|
7
|
+
Measuremerize.measure do
|
8
|
+
...
|
9
|
+
end
|
10
|
+
```
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'measuremerize'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install measuremerize
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
For garbage collection measuring you can do this
|
31
|
+
|
32
|
+
```
|
33
|
+
Measuremerize.measure do
|
34
|
+
...
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
Otherwise you can disable garbage collection with the argument ``` true ```
|
39
|
+
|
40
|
+
```
|
41
|
+
Measuremerize.measure(true) do
|
42
|
+
...
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it ( https://github.com/iamkristian/measuremerize/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "measuremerize"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require 'json'
|
3
|
+
require "measuremerize/version"
|
4
|
+
|
5
|
+
module Measuremerize
|
6
|
+
|
7
|
+
def self.measure(no_gc_arg = false, &block)
|
8
|
+
no_gc = (ARGV[0] == '--no-gc') || no_gc_arg
|
9
|
+
|
10
|
+
if no_gc
|
11
|
+
GC.disable
|
12
|
+
else
|
13
|
+
GC.start
|
14
|
+
end
|
15
|
+
|
16
|
+
memory_before = Measuremerize.memory_used
|
17
|
+
gc_stat_before = GC.stat
|
18
|
+
time = Benchmark.realtime do
|
19
|
+
yield
|
20
|
+
end
|
21
|
+
|
22
|
+
gc_stat_after = GC.stat
|
23
|
+
GC.start unless no_gc
|
24
|
+
memory_after = Measuremerize.memory_used
|
25
|
+
result = Measuremerize.result(no_gc, time, gc_stat_before, gc_stat_after, memory_before, memory_after)
|
26
|
+
puts result
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.memory_used
|
30
|
+
`ps -o rss= -p #{Process.pid}`.to_i/1024
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.result(no_gc, time, gc_stat_before, gc_stat_after, memory_before, memory_after)
|
36
|
+
{
|
37
|
+
RUBY_VERSION => {
|
38
|
+
gc: no_gc ? 'disabled' : 'enabled',
|
39
|
+
time: time.round(2),
|
40
|
+
gc_count: gc_stat_after[:count] - gc_stat_before[:count],
|
41
|
+
memory: "%dM" % (memory_after- memory_before)
|
42
|
+
}
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
@@ -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 'measuremerize/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "measuremerize"
|
8
|
+
spec.version = Measuremerize::VERSION
|
9
|
+
spec.authors = ["Kristian Rasmussen"]
|
10
|
+
spec.email = ["me@krx.io"]
|
11
|
+
spec.summary = %q{A collection of measuring tools for ruby benchmarks}
|
12
|
+
spec.description = %q{Memory and time measuring for ruby profiling}
|
13
|
+
spec.homepage = "http://github.com/iamkristian/measuremerize"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: measuremerize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kristian Rasmussen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-30 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.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Memory and time measuring for ruby profiling
|
42
|
+
email:
|
43
|
+
- me@krx.io
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- lib/measuremerize.rb
|
57
|
+
- lib/measuremerize/version.rb
|
58
|
+
- measuremerize.gemspec
|
59
|
+
homepage: http://github.com/iamkristian/measuremerize
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.4.5
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: A collection of measuring tools for ruby benchmarks
|
83
|
+
test_files: []
|
84
|
+
has_rdoc:
|