Rails 一个得到 Ruby 代码运行时间的函数 Benchmark

ailen · April 11, 2013 · Last by chenge replied at July 04, 2016 · 7095 hits

分享一个不错的 Ruby API Benchmark

运行 Benchmark.measure { xx_method}就可有得到 xx_method 运行的时间。对比一些方法优劣和效率选择有很大帮助。

很久之前写了一个小工具,https://github.com/allenwei/tick 打印一个方法的用时

@allenwei 貌似是从 ruby2.0 才有了这个 api 😄,我也是为了调试方法的效率才找到这个

这个 api 1.8 就有了

chenge in Ruby 学习汇集,请推荐内容 mention this topic. 04 Jul 11:35
You need to Sign in before reply, if you don't have an account, please Sign up first.