Rails开发中的性能分析、模拟对象与目录结构详解
1. 性能分析
在开发过程中,有时需要对代码进行性能分析,以找出性能瓶颈。例如,运行如下命令对 User.encrypted_password 方法进行性能分析:
depot> ruby script/performance/profiler 'User.encrypted_password("secret", "salt")'
运行结果如下:
| % time | cumulative seconds | self seconds | calls | ms/call (self) | ms/call (total) | name |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| 78.65 | 58.63 | 58.63 | 1 | 58630.00 | 74530.00 | Integer#times |
| 21.33 | 74.53 | 15.90 | 1000000 | 0.02 | 0.02 | Math.sin |
| 1.25 | 75.46 | 0.93 | 1 | 930.00 | 930.00 | Profiler__.start_profile |
| 0.01 | 75.47 | 0.01 | 12 | 0.83 | 0.83 | Symbol#to_sym |
| 0.00 | 75.48 | 0.00 | 1 | 0.00 | 0.00 | Hash#updat
超级会员免费看
订阅专栏 解锁全文
26

被折叠的 条评论
为什么被折叠?



