-
Notifications
You must be signed in to change notification settings - Fork 31
Add a simple benchmark for ActiveRecord #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Cool. You're right that the measurements are very noisy. Too noisy to really conclude anything ATM. Good move trying it on AWS. I would like to see the running time and complexity increased a bit. Maybe adding more iterations, creating more posts, and adding a few extra fields to the schema (what kind of fields would a realistic web forum have on a post, for instance, maybe upvotes, author_id, etc?). |
This benchmark just creates a bunch of records in an in-memory database and then reads the records back out. The "read" is the part that is being measured
6c85435 to
cdfbc21
Compare
|
I added more columns and increased the iterations. Benchmark results on my machine look like this: |
|
Perfect! |
|
|
||
| run_benchmark(10) do | ||
| 1000.times do |i| | ||
| Post.where(id: i + 1).first.title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #207 (comment)
THe initial snapshot was from a few years back, the application changed a lot since then. I had to run a bunch of migrations and had to fiddle with various sqlite3/msyql incompatibilities. Also some route changes, but with a bit of effort I managed to make it work again. What is interesting is it seems lobste.rs became 2-3-x as slow in these couple years, I haven't yet profiled to know why. This branch: ``` itr: time ruby#1: 1532ms ruby#2: 1013ms ruby#3: 910ms ruby#4: 852ms ruby#5: 851ms ruby#6: 901ms ruby#7: 857ms ruby#8: 886ms ruby#9: 875ms ``` main: ``` itr: time ruby#1: 884ms ruby#2: 482ms ruby#3: 344ms ruby#4: 358ms ruby#5: 300ms ruby#6: 316ms ruby#7: 315ms ruby#8: 328ms ruby#9: 309ms ```
THe initial snapshot was from a few years back, the application changed a lot since then. I had to run a bunch of migrations and had to fiddle with various sqlite3/msyql incompatibilities. Also some route changes, but with a bit of effort I managed to make it work again. What is interesting is it seems lobste.rs became 2-3-x as slow in these couple years, I haven't yet profiled to know why. This branch: ``` itr: time ruby#1: 1532ms ruby#2: 1013ms ruby#3: 910ms ruby#4: 852ms ruby#5: 851ms ruby#6: 901ms ruby#7: 857ms ruby#8: 886ms ruby#9: 875ms ``` main: ``` itr: time ruby#1: 884ms ruby#2: 482ms ruby#3: 344ms ruby#4: 358ms ruby#5: 300ms ruby#6: 316ms ruby#7: 315ms ruby#8: 328ms ruby#9: 309ms ```
This benchmark just creates a bunch of records in an in-memory database
and then reads the records back out. The "read" is the part that is
being measured
My machine seems kind of noisy (the stddev is high), but here are the results: