This file contains hidden or 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
| require 'benchmark/ips' | |
| bar = 'bar' | |
| Benchmark.ips do |r| | |
| r.report('concatenation') { 'foo' << bar } | |
| r.report('interpolation') { "foo#{bar}" } | |
| end |
This file contains hidden or 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
| require 'benchmark/ips' | |
| class Foo1 | |
| def initialize | |
| @bar = :bar | |
| end | |
| attr_reader :bar | |
| end |
This file contains hidden or 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
| Calculating ------------------------------------- | |
| symbol 51632 i/100ms | |
| string 46997 i/100ms | |
| ------------------------------------------------- | |
| symbol 2537871.3 (±1.1%) i/s - 12701472 in 5.005420s | |
| string 1664204.2 (±7.7%) i/s - 8271472 in 5.012292s |
This file contains hidden or 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
| require 'active_record' | |
| require 'benchmark/ips' | |
| ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
| class Post < ActiveRecord::Base | |
| connection.create_table :posts do |t| | |
| t.string :name | |
| end | |
| end |
This file contains hidden or 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
| require 'benchmark/ips' | |
| class A | |
| def initialize | |
| @attributes = { :foo => 1 } | |
| end | |
| def foo | |
| @attributes[:foo] | |
| end |
This file contains hidden or 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
| $ ruby test.rb | |
| Calculating ------------------------------------- | |
| success 51960 i/100ms | |
| failure 4653 i/100ms | |
| ------------------------------------------------- | |
| success 2687778.5 (±3.7%) i/s - 13405680 in 4.996239s | |
| failure 53863.7 (±3.5%) i/s - 269874 in 5.016999s |
This file contains hidden or 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
| $ ruby test.rb false | |
| 0.210000 0.000000 0.210000 ( 0.212155) | |
| $ ruby test.rb true | |
| 10.000000 0.280000 10.280000 ( 10.773232) |
This file contains hidden or 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
| Generating data... | |
| Inserting 20000 users and exhibits... | |
| Calculating ------------------------------------- | |
| Model#id 9279 i/100ms | |
| Model.new (instantiation) | |
| 2056 i/100ms | |
| Model.new (setting attributes) | |
| 890 i/100ms | |
| Model.first 178 i/100ms | |
| Model.all limit(100) 5 i/100ms |
This file contains hidden or 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
| require 'benchmark/ips' | |
| h = { foo: :bar } | |
| Benchmark.ips do |r| | |
| r.report('#[]') { h[:foo] } | |
| r.report('#fetch') { h.fetch(:foo) } | |
| end |
This file contains hidden or 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
| Operating system: Mac OS X | |
| 10.7.4 11E53 | |
| CPU: x86 | |
| GenuineIntel family 6 model 42 stepping 7 | |
| 4 CPUs | |
| Crash reason: EXC_BAD_ACCESS / KERN_INVALID_ADDRESS | |
| Crash address: 0x6e6f4640 | |
| Thread 0 (crashed) |