whysoslow 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,6 +1,19 @@
1
- pkg/*
2
- .bundle
3
1
  *.gem
4
2
  *.log
5
- .rvmrc
6
- .rbenv-version
3
+ *.rbc
4
+ .rbx/
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify dependencies in whysoslow.gemspec
4
3
  gemspec
5
4
 
6
- gem 'rake', '~>0.9.2'
5
+ gem 'rake'
6
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012-Present Kelly Redding
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,52 @@
1
+ # Whysoslow
2
+
3
+ ## Description
4
+
5
+ Whysoslow is a little runner/printer I wrote to benchmark my Ruby code. It runs a block of code, collects run time measurements, and can snapshot memory usage information at various points during execution.
6
+
7
+ It has no tests, shockingly sparse docs, and is more of an experiment at this point. It comes as is for now so use if you see fit. I will happily accept any pull requests for documentation, tests, extensions, and improvements.
8
+
9
+ ## Usage
10
+
11
+ ```ruby
12
+ require 'whysoslow'
13
+
14
+ printer = Whysoslow::DefaultPrinter.new({
15
+ :title => "Bench Report Title",
16
+ :verbose => true
17
+ })
18
+
19
+ runner = Whysoslow::Runner.new(@printer)
20
+
21
+ runner.run do
22
+ # ... some long running script or loop
23
+ runner.snapshot("mem usage during run")
24
+ # ... some more long running script or loop
25
+ end
26
+ ```
27
+
28
+ ## Output: DefaultPrinter
29
+
30
+ The DefaultPrinter outputs to an io stream ($stdout by default). It uses Ansi to output columned memory usage snapshot data and measurement data.
31
+
32
+ ## Installation
33
+
34
+ Add this line to your application's Gemfile:
35
+
36
+ gem 'whysoslow'
37
+
38
+ And then execute:
39
+
40
+ $ bundle
41
+
42
+ Or install it yourself as:
43
+
44
+ $ gem install whysoslow
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,7 +1 @@
1
- require 'assert/rake_tasks'
2
- Assert::RakeTasks.for(:test)
3
-
4
- require 'bundler'
5
- Bundler::GemHelper.install_tasks
6
-
7
- task :default => :build
1
+ require "bundler/gem_tasks"
data/lib/whysoslow.rb CHANGED
@@ -1,4 +1,6 @@
1
- module Whysoslow; end
2
-
3
- require 'whysoslow/runner'
1
+ require 'whysoslow/version'
4
2
  require 'whysoslow/default_printer'
3
+ require 'whysoslow/runner'
4
+
5
+ module Whysoslow
6
+ end
@@ -1,9 +1,6 @@
1
1
  module Whysoslow
2
-
3
2
  class MemoryProfile
4
3
 
5
- class Snapshot; end
6
-
7
4
  attr_reader :snapshots, :divider
8
5
  attr_accessor :units
9
6
 
@@ -21,26 +18,23 @@ module Whysoslow
21
18
  end
22
19
 
23
20
  def snapshot(label)
24
- Snapshot.new(label, @divider).tap { |snap| @snapshots.push(snap) }
21
+ Snapshot.new(label, @divider).tap{ |snap| @snapshots.push(snap) }
25
22
  end
26
23
 
27
- end
28
-
29
- class MemoryProfile::Snapshot
30
-
31
- attr_reader :label, :memory
24
+ class Snapshot
25
+ attr_reader :label, :memory
32
26
 
33
- def initialize(label, divider)
34
- @label = label
35
- @memory = capture_memory_usage(divider)
36
- end
27
+ def initialize(label, divider)
28
+ @label = label
29
+ @memory = capture_memory_usage(divider)
30
+ end
37
31
 
38
- protected
32
+ protected
39
33
 
40
- def capture_memory_usage(divider)
41
- ((`ps -o rss= -p #{$$}`.to_i) / divider.to_f)
34
+ def capture_memory_usage(divider)
35
+ ((`ps -o rss= -p #{$$}`.to_i) / divider.to_f)
36
+ end
42
37
  end
43
38
 
44
39
  end
45
-
46
40
  end
@@ -1,7 +1,6 @@
1
1
  require 'whysoslow/results'
2
2
 
3
3
  module Whysoslow
4
-
5
4
  class Runner
6
5
 
7
6
  attr_accessor :desc, :verbose, :time_unit, :memory_unit
@@ -27,7 +26,10 @@ module Whysoslow
27
26
  end
28
27
 
29
28
  def snapshot(*args)
30
- raise RuntimeError, "no active results being gathered - be sure and call snapshot during a run session" if @results.nil?
29
+ if @results.nil?
30
+ raise RuntimeError, "no active results being gathered"\
31
+ " - be sure and call snapshot during a run session"
32
+ end
31
33
  @results.snapshot(*args)
32
34
  @printer.print :snapshot
33
35
  end
@@ -1,3 +1,3 @@
1
1
  module Whysoslow
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
data/test/helper.rb CHANGED
@@ -1,5 +1,8 @@
1
- # this file is automatically required in when you require 'assert' in your tests
2
- # put test helpers here
1
+ # this file is automatically required when you run `assert`
2
+ # put any test helpers here
3
3
 
4
- # add root dir to the load path
4
+ # add the root dir to the load path
5
5
  $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
+
7
+ # require pry for debugging (`binding.pry`)
8
+ require 'pry'
@@ -0,0 +1,17 @@
1
+ require 'assert'
2
+ require 'whysoslow'
3
+
4
+ module Whysoslow
5
+
6
+ class UnitTests < Assert::Context
7
+ desc "Whysoslow"
8
+
9
+ # no tests right now - all this does is make sure you can load it
10
+
11
+ should "load" do
12
+ assert_equal false, require('whysoslow')
13
+ end
14
+
15
+ end
16
+
17
+ end
data/whysoslow.gemspec CHANGED
@@ -1,23 +1,25 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
4
  require "whysoslow/version"
4
5
 
5
- Gem::Specification.new do |s|
6
- s.name = "whysoslow"
7
- s.version = Whysoslow::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Kelly Redding"]
10
- s.email = ["kelly@kellyredding.com"]
11
- s.homepage = "http://github.com/kellyredding/whysoslow"
12
- s.summary = %q{A little runner/printer to benchmark Ruby code blocks}
13
- s.description = %q{A little runner/printer to benchmark Ruby code blocks}
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "whysoslow"
8
+ gem.version = Whysoslow::VERSION
9
+ gem.authors = ["Kelly Redding"]
10
+ gem.email = ["kelly@kellyredding.com"]
11
+ gem.description = %q{A little runner/printer to benchmark Ruby code blocks}
12
+ gem.summary = %q{A little runner/printer to benchmark Ruby code blocks}
13
+ gem.homepage = "http://github.com/kellyredding/whysoslow"
14
+ gem.license = 'MIT'
14
15
 
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_development_dependency("assert", ["~> 2.0"])
22
+
23
+ gem.add_dependency("ansi", ["~> 1.4"])
19
24
 
20
- s.add_development_dependency("bundler")
21
- s.add_development_dependency("assert")
22
- s.add_dependency("ansi", "~> 1.4")
23
25
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whysoslow
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
9
  - 0
9
- - 2
10
- version: 0.0.2
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -15,40 +15,27 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-20 00:00:00 Z
18
+ date: 2013-07-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- type: :development
21
+ name: assert
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
- - - ">="
26
+ - - ~>
27
27
  - !ruby/object:Gem::Version
28
28
  hash: 3
29
29
  segments:
30
+ - 2
30
31
  - 0
31
- version: "0"
32
+ version: "2.0"
33
+ type: :development
32
34
  version_requirements: *id001
33
- name: bundler
34
35
  - !ruby/object:Gem::Dependency
35
- type: :development
36
+ name: ansi
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
46
- version_requirements: *id002
47
- name: assert
48
- - !ruby/object:Gem::Dependency
49
- type: :runtime
50
- prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
39
  none: false
53
40
  requirements:
54
41
  - - ~>
@@ -58,8 +45,8 @@ dependencies:
58
45
  - 1
59
46
  - 4
60
47
  version: "1.4"
61
- version_requirements: *id003
62
- name: ansi
48
+ type: :runtime
49
+ version_requirements: *id002
63
50
  description: A little runner/printer to benchmark Ruby code blocks
64
51
  email:
65
52
  - kelly@kellyredding.com
@@ -72,8 +59,8 @@ extra_rdoc_files: []
72
59
  files:
73
60
  - .gitignore
74
61
  - Gemfile
75
- - Gemfile.lock
76
- - README.rdoc
62
+ - LICENSE.txt
63
+ - README.md
77
64
  - Rakefile
78
65
  - lib/whysoslow.rb
79
66
  - lib/whysoslow/default_printer.rb
@@ -83,12 +70,11 @@ files:
83
70
  - lib/whysoslow/runner.rb
84
71
  - lib/whysoslow/version.rb
85
72
  - test/helper.rb
86
- - test/irb.rb
87
- - test/whysoslow_test.rb
73
+ - test/unit/whysoslow_test.rb
88
74
  - whysoslow.gemspec
89
75
  homepage: http://github.com/kellyredding/whysoslow
90
- licenses: []
91
-
76
+ licenses:
77
+ - MIT
92
78
  post_install_message:
93
79
  rdoc_options: []
94
80
 
@@ -115,11 +101,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
101
  requirements: []
116
102
 
117
103
  rubyforge_project:
118
- rubygems_version: 1.8.11
104
+ rubygems_version: 1.8.24
119
105
  signing_key:
120
106
  specification_version: 3
121
107
  summary: A little runner/printer to benchmark Ruby code blocks
122
108
  test_files:
123
109
  - test/helper.rb
124
- - test/irb.rb
125
- - test/whysoslow_test.rb
110
+ - test/unit/whysoslow_test.rb
data/Gemfile.lock DELETED
@@ -1,26 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- whysoslow (0.0.2)
5
- ansi (~> 1.4)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- ansi (1.4.2)
11
- assert (0.7.3)
12
- assert-view (~> 0.5)
13
- assert-view (0.5.0)
14
- ansi (~> 1.3)
15
- undies (~> 2.0)
16
- rake (0.9.2.2)
17
- undies (2.2.0)
18
-
19
- PLATFORMS
20
- ruby
21
-
22
- DEPENDENCIES
23
- assert
24
- bundler
25
- rake (~> 0.9.2)
26
- whysoslow!
data/README.rdoc DELETED
@@ -1,59 +0,0 @@
1
- = Whysoslow
2
-
3
- == Description
4
-
5
- Whysoslow is a little runner/printer I wrote to benchmark my Ruby code. It runs a block of code, collects run time measurements, and can snapshot memory usage information at various points during execution.
6
-
7
- It has no tests, shockingly sparse docs, and is more of an experiment at this point. It comes as is for now so use if you see fit.
8
-
9
- I will happily accept any pull requests for documentation, tests, extensions, and improvements.
10
-
11
- == Installation
12
-
13
- gem install whysoslow
14
-
15
- == Usage
16
-
17
- require 'whysoslow'
18
-
19
- printer = Whysoslow::DefaultPrinter.new({
20
- :title => "Bench Report Title",
21
- :verbose => true
22
- })
23
-
24
- runner = Whysoslow::Runner.new(@printer)
25
-
26
- runner.run do
27
- # ... some long running script or loop
28
- runner.snapshot("mem usage during run")
29
- # ... some more long running script or loop
30
- end
31
-
32
- == Output: DefaultPrinter
33
-
34
- The DefaultPrinter outputs to an io stream ($stdout by default). It uses Ansi to output columned memory usage snapshot data and measurement data.
35
-
36
- == License
37
-
38
- Copyright (c) 2012 Kelly Redding
39
-
40
- Permission is hereby granted, free of charge, to any person
41
- obtaining a copy of this software and associated documentation
42
- files (the "Software"), to deal in the Software without
43
- restriction, including without limitation the rights to use,
44
- copy, modify, merge, publish, distribute, sublicense, and/or sell
45
- copies of the Software, and to permit persons to whom the
46
- Software is furnished to do so, subject to the following
47
- conditions:
48
-
49
- The above copyright notice and this permission notice shall be
50
- included in all copies or substantial portions of the Software.
51
-
52
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
53
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
54
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
55
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
56
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
57
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
58
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
59
- OTHER DEALINGS IN THE SOFTWARE.
data/test/irb.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'assert/setup'
2
-
3
- # this file is required in when the 'irb' rake test is run.
4
- # b/c 'assert/setup' is required above, the test helper will be
5
- # required in as well.
6
-
7
- # put any IRB setup code here
8
-
9
- require 'whysoslow'
@@ -1,4 +0,0 @@
1
- require "assert"
2
-
3
- class WhysoslowTest < Assert::Context
4
- end