Created
January 24, 2013 03:27
-
-
Save wangjohn/4617394 to your computer and use it in GitHub Desktop.
Benchmarking test using ObjectSpace._id2ref() vs the current rails implementation of @records.each.
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
Test Code: | |
def test_benchmark_of_transactions | |
time = Benchmark.measure do | |
500.times do | |
Topic.transaction do | |
10000.times do | |
Topic.new | |
end | |
end | |
end | |
end | |
puts time | |
end | |
Using ruby 1.9.3p194. | |
Current Rails Implementation Results: | |
$ ruby -Itest test/cases/transactions_test.rb -n test_benchmark_of_transactions | |
Using sqlite3 | |
Run options: -n test_benchmark_of_transactions --seed 30080 | |
# Running tests: | |
673.210000 0.170000 673.380000 (679.856112) | |
Finished tests in 680.141154s, 0.0015 tests/s, 0.0000 assertions/s. | |
1 tests, 0 assertions, 0 failures, 0 errors, 0 skips | |
ObjectSpace._id2ref() Results: | |
$ ruby -Itest test/cases/transactions_test.rb -n test_benchmark_of_transactions | |
test test/cases/transactions_test.rb -n test_benchmark_of_transactions | |
Using sqlite3 | |
Run options: -n test_benchmark_of_transactions --seed 39892 | |
# Running tests: | |
676.260000 0.010000 676.270000 (676.878263) | |
Finished tests in 677.190547s, 0.0015 tests/s, 0.0000 assertions/s. | |
1 tests, 0 assertions, 0 failures, 0 errors, 0 skips |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment