-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from kbrock/save_results
Save job (alternative to hold)
- Loading branch information
Showing
9 changed files
with
173 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# example to explain save! | ||
# The save! feature expects to be run twice, generally with different Rubys. | ||
# save! can also be used to compare modules changes which impact the run time | ||
# | ||
# If you're comparing ruby versions, Just use the version in the label | ||
# | ||
# x.report("ruby #{RUBY_VERSION}") { 'Bruce'.inspect } | ||
# | ||
# Or use a hash | ||
# | ||
# x.report("version" => RUBY_VERSION, "method" => 'bruce') { 'Bruce'.inspect } | ||
# | ||
# RUN_1: SAVE_FILE='run1.out' ruby examples/hold.rb | ||
# Warming up -------------------------------------- | ||
# without 172.168k i/100ms | ||
# Calculating ------------------------------------- | ||
# without 2.656M (± 3.3%) i/s - 13.429M in 5.062098s | ||
# | ||
# RUN_2: SAVE_FILE='run1.out' WITH_MODULE=true ruby examples/hold.rb | ||
# Warming up -------------------------------------- | ||
# with 92.087k i/100ms | ||
# Calculating ------------------------------------- | ||
# with 1.158M (± 1.4%) i/s - 5.801M in 5.010084s | ||
# | ||
# Comparison: | ||
# without: 2464721.3 i/s | ||
# with: 1158179.6 i/s - 2.13x slower | ||
# CLEANUP: rm run1.out | ||
|
||
require 'benchmark/ips' | ||
|
||
Benchmark.ips do |x| | ||
x.report(ENV['WITH_MODULE'] == 'true' ? 'with' : 'without') do | ||
'Bruce'.inspect | ||
end | ||
|
||
if ENV['WITH_MODULE'] == 'true' | ||
class String | ||
def inspect | ||
result = %w[Bruce Wayne is Batman] | ||
result.join(' ') | ||
end | ||
end | ||
end | ||
|
||
x.save! ENV['SAVE_FILE'] if ENV['SAVE_FILE'] | ||
x.compare! | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.