开发者

What are some techniques for testing optimizations to ActiveRecord bulk model object creation?

开发者 https://www.devze.com 2023-04-10 03:45 出处:网络
I am in the process of optimizing a contact importer tool that process a large list of email address and creates contact objects.

I am in the process of optimizing a contact importer tool that process a large list of email address and creates contact objects.

The brunt of the changes will involve creating the contacts all at once rather than individually using standard ActiveRecord.create. I understand how to test that this functionality works correctly but I am not sure of best practices for testing the performance improvement gained from the optimization work.

What techniques are considered good practice for testing optimization improvements and code performance in a TDD work fl开发者_如何学JAVAow?

For this specific case, I am in a Rails 3 stack optimizing bulk model object creation being stored in a mysql db. I am testing my code using rspec with a TDD work flow.


While I am not 100% happy with this approach, what I ended up doing here was using the standard Rails benchmarking test abilities. A tutorial for how to do this can be found at http://guides.rubyonrails.org/performance_testing.html.

Here you can write tests that will profile based on time, memory usage and a number of other things using rake test:benchmark

0

精彩评论

暂无评论...
验证码 换一张
取 消