irb-benchmark 0.1.0

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.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "jeweler", "~> 1.8.4"
5
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.8.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rdoc
10
+ json (1.7.5)
11
+ rake (0.9.2.2)
12
+ rdoc (3.12)
13
+ json (~> 1.4)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ jeweler (~> 1.8.4)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Maurizio De Santis
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.rdoc ADDED
@@ -0,0 +1,43 @@
1
+ = IrbBenchmark
2
+
3
+ == Description
4
+
5
+ It wraps irb evaluations in a <tt>Benchmark.measure{ ... }</tt> block and displays
6
+ the results after the command execution. Simple and powerful.
7
+
8
+ == Installation
9
+
10
+ <tt>gem install irb-benchmark</tt>
11
+
12
+ == Usage
13
+
14
+ Single shot usage: open irb and <tt>require 'irb_benchmark'</tt>
15
+
16
+ In <tt>.irbrc</tt>:
17
+ * classic require: <tt>require 'irb_benchmark'</tt>
18
+ * irbtools option: <tt>Irbtools.add_library :irb_benchmark, :late => true</tt> (require can be used with irbtools too)
19
+
20
+ Enabling / disabling: <tt>IrbBenchmark.enabled = true / false</tt>
21
+
22
+ == Wirb / irbtools integration
23
+
24
+ It auto-detects Wirb[https://github.com/janlelis/wirb] presence and
25
+ FancyIrb[https://github.com/janlelis/fancy_irb] configuration for colorized
26
+ output (both are used by the well-known
27
+ irbtools[https://github.com/janlelis/irbtools] gem).
28
+
29
+ == Known issues
30
+
31
+ The usage with FancyIrb alters the benchmark measures adding a small overhead;
32
+ I'm working on it.
33
+
34
+ == Bugs, feature requests, pull requests
35
+
36
+ Fell free to open an issue[https://github.com/ProGNOMmers/irb-benchmark/issues]
37
+ for problems or feature requests, or fork it and make a pull request, it will
38
+ be taken in consideration.
39
+
40
+ == Copyright
41
+
42
+ Copyright (c) 2012 Maurizio De Santis. See LICENSE.txt for
43
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
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://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "irb-benchmark"
18
+ gem.homepage = "http://github.com/ProGNOMmers/irb-benchmark"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Auto-benchmarking of irb commands}
21
+ gem.description = %Q{irb-benchmark wraps irb commands in a Benchmark.measure{ ... } block and displays
22
+ the results after the command execution}
23
+ gem.email = "desantis.maurizio@gmail.com"
24
+ gem.authors = ["Maurizio De Santis"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rdoc/task'
30
+ Rake::RDocTask.new do |rdoc|
31
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
32
+
33
+ rdoc.rdoc_dir = 'rdoc'
34
+ rdoc.title = "irb-benchmark #{version}"
35
+ rdoc.rdoc_files.include('README*')
36
+ rdoc.rdoc_files.include('lib/**/*.rb')
37
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,23 @@
1
+ module IrbBenchmark
2
+
3
+ VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).chomp.freeze
4
+
5
+ @enabled = true
6
+
7
+ class << self
8
+
9
+ attr_accessor :enabled
10
+
11
+ def print(bm)
12
+ if defined?(Wirb) and (!defined?(FancyIrb) || FancyIrb[:colorize, :output])
13
+ $stdout.print Wirb.colorize_result bm.inspect
14
+ else
15
+ $stdout.print bm.inspect
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+
23
+ require 'irb_benchmark/irb_ext'
@@ -0,0 +1,18 @@
1
+ require 'irb'
2
+ require 'benchmark'
3
+
4
+ module IRB
5
+ class Context
6
+
7
+ alias evaluate_non_benchmarked evaluate
8
+
9
+ def evaluate(*args)
10
+ if IrbBenchmark.enabled
11
+ IrbBenchmark.print Benchmark.measure{ evaluate_non_benchmarked(*args) }
12
+ else
13
+ evaluate_non_benchmarked(*args)
14
+ end
15
+ end
16
+
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: irb-benchmark
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Maurizio De Santis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jeweler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.8.4
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.8.4
30
+ description: ! "irb-benchmark wraps irb commands in a Benchmark.measure{ ... } block
31
+ and displays \nthe results after the command execution"
32
+ email: desantis.maurizio@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files:
36
+ - LICENSE.txt
37
+ - README.rdoc
38
+ files:
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE.txt
42
+ - README.rdoc
43
+ - Rakefile
44
+ - VERSION
45
+ - lib/irb_benchmark.rb
46
+ - lib/irb_benchmark/irb_ext.rb
47
+ homepage: http://github.com/ProGNOMmers/irb-benchmark
48
+ licenses:
49
+ - MIT
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ segments:
61
+ - 0
62
+ hash: 642731209741343320
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 1.8.24
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Auto-benchmarking of irb commands
75
+ test_files: []