diff options
author | wangjohn <wangjohn@mit.edu> | 2013-05-08 13:14:12 -0400 |
---|---|---|
committer | wangjohn <wangjohn@mit.edu> | 2013-05-08 13:47:56 -0400 |
commit | eb93d16e49e0582a42b9f1460c41b517dd7044b3 (patch) | |
tree | ec1552da1cc672c458b3e0e97348cce44fba1cfc /railties/lib | |
parent | 1ff1236b079d379bbf0ceaf19d7efc3ee97d0406 (diff) | |
download | rails-eb93d16e49e0582a42b9f1460c41b517dd7044b3.tar.gz rails-eb93d16e49e0582a42b9f1460c41b517dd7044b3.tar.bz2 rails-eb93d16e49e0582a42b9f1460c41b517dd7044b3.zip |
Using define method instead of class eval when defining model callbacks.
Based on my benchmark results, this change improves performance
substantially when defining callbacks.
This benchmark (https://gist.github.com/wangjohn/5542610) was run using
the current master and also using my experimental branch which replaced
class_eval with define_single_method.
Using class_eval (current master):
user system total real
10 trials 0.000000 0.000000 0.000000 ( 0.001568)
50 trials 0.020000 0.000000 0.020000 ( 0.021715)
500 trials 0.110000 0.000000 0.110000 ( 0.115357)
1000 trials 0.250000 0.000000 0.250000 ( 0.260025)
10000 trials 2.560000 0.000000 2.560000 ( 2.568408)
50000 trials 12.800000 0.010000 12.810000 ( 12.886871)
Using define_single_method (experimental branch):
user system total real
10 trials 0.000000 0.000000 0.000000 ( 0.000790)
50 trials 0.000000 0.000000 0.000000 ( 0.002960)
500 trials 0.050000 0.010000 0.060000 ( 0.055690)
1000 trials 0.100000 0.000000 0.100000 ( 0.094073)
10000 trials 0.890000 0.000000 0.890000 ( 0.900364)
50000 trials 4.650000 0.000000 4.650000 ( 4.686127)
Diffstat (limited to 'railties/lib')
0 files changed, 0 insertions, 0 deletions