Module: Viiite
- Defined in:
- lib/viiite.rb,
lib/viiite/bdb.rb,
lib/viiite/tms.rb,
lib/viiite/errors.rb,
lib/viiite/command.rb,
lib/viiite/version.rb,
lib/viiite/bdb/utils.rb,
lib/viiite/benchmark.rb,
lib/viiite/bdb/cached.rb,
lib/viiite/command/run.rb,
lib/viiite/command/help.rb,
lib/viiite/command/plot.rb,
lib/viiite/bdb/immediate.rb,
lib/viiite/command/report.rb,
lib/viiite/command/commons.rb,
lib/viiite/benchmark/runner.rb,
lib/viiite/command/plot/to_text.rb,
lib/viiite/command/plot/to_gnuplot.rb,
lib/viiite/command/plot/to_highcharts.rb
Overview
Benchmarking and complexity analyzer utility
Defined Under Namespace
Modules: Version Classes: BDB, Benchmark, Command, Error, InvalidPattern, NoSuchBenchmarkError, Tms
Constant Summary collapse
Class Method Summary collapse
-
.bench(&block) ⇒ Object
Builds a runner instance via the DSL definition given by the block.
-
.bm(&block) ⇒ Object
Alias of Viiite.bench for compatibility.
- .measure ⇒ Object
- .short_ruby_description(description) ⇒ Object
-
.Tms(*args) ⇒ Object
class Tms.
-
.which_ruby ⇒ Object
Returns a short string with a ruby interpreter description.
Class Method Details
.bench(&block) ⇒ Object
Builds a runner instance via the DSL definition given by the block.
Example
Viiite.bench do |b|
b.variation_point :ruby_version, Viiite.which_ruby
b.range_over([100, 1000, 10000, 100000], :runs) do |runs|
b.variation_point :test, :via_reader do
b.report{ runs.times{ foo.via_reader } }
end
b.variation_point :test, :via_method do
b.report{ runs.times{ foo.via_method } }
end
end
end
44 45 46 |
# File 'lib/viiite.rb', line 44 def self.bench(&block) Benchmark.new(block) end |
.bm(&block) ⇒ Object
Alias of Viiite.bench for compatibility
49 50 51 52 |
# File 'lib/viiite.rb', line 49 def self.bm(&block) warn "Viiite.bm is deprecated, use Viiite.bench instead #{caller[0]}" bench(&block) end |
.measure ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/viiite.rb', line 17 def self.measure t0, r0 = Process.times, Time.now yield t1, r1 = Process.times, Time.now Tms.new(t1.utime - t0.utime, t1.stime - t0.stime, t1.cutime - t0.cutime, t1.cstime - t0.cstime, r1 - r0) end |
.short_ruby_description(description) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/viiite.rb', line 65 def self.short_ruby_description(description) case description when /Ruby Enterprise Edition (\d{4}\.\d{2})/ "ree #{$1}" when /^(\w+ \d\.\d\.\d) .+ patchlevel (\d+)/ "#{$1}p#{$2}" when /^\w+ \S+/ $& else raise "Unknown ruby interpreter: #{description}" end end |
.Tms(*args) ⇒ Object
class Tms
76 77 78 |
# File 'lib/viiite/tms.rb', line 76 def self.Tms(*args) Viiite::Tms.new(*args) end |
.which_ruby ⇒ Object
Returns a short string with a ruby interpreter description
57 58 59 60 61 62 63 |
# File 'lib/viiite.rb', line 57 def self.which_ruby if Object.const_defined?(:RUBY_DESCRIPTION) short_ruby_description(RUBY_DESCRIPTION) else "ruby #{RUBY_VERSION}" end end |