【文件属性】:
文件名称:benchmark_methods:对Ruby方法进行基准测试并衡量其执行时间,而无需进行其他代码更改
文件大小:84KB
文件格式:ZIP
更新时间:2021-05-04 21:05:41
Ruby
基准方法
测量并确定Ruby方法的执行时间。 忘记了Time.now - t解决方案。 使用benchmark来查看执行您的方法需要多少时间。
样品或用法:
安装
将此行添加到您的应用程序的Gemfile中:
gem 'benchmark_methods'
然后执行:
$ bundle
或将其自己安装为:
$ gem install benchmark_methods
注意:仅适用于Ruby 2+
用法
假设您有使用两个方法的样本模型User :
class User < ActiveRecord :: Base
include BenchmarkMethods
benchmark :generate_report
cbenchmark :import_users
def generate_report
report = reports . create
【文件预览】:
benchmark_methods-master
----.gitignore(101B)
----.rspec(31B)
----benchmark_methods.gemspec(1KB)
----bin()
--------setup(115B)
--------console(342B)
----.travis.yml(247B)
----CODE_OF_CONDUCT.md(1KB)
----LICENSE.txt(1KB)
----.github()
--------FUNDING.yml(24B)
----spec()
--------methods_benchmarker_spec.rb(626B)
--------app.rb(1KB)
--------spec_helper.rb(292B)
----README.md(3KB)
----lib()
--------benchmark_methods.rb(2KB)
--------string_ext.rb(141B)
--------benchmark_methods()
----Gemfile(226B)
----Rakefile(28B)
----benchmark_methods.png(79KB)