1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

6 commits

Author SHA1 Message Date
aycabta
1d03c7da04 [ruby/irb] Add an explanation of default sub commands of "measure", which are :time and :stackprof
759be5a344
2021-07-13 21:21:29 +09:00
aycabta
5704b5fe5e [ruby/irb] Allow "measure" command to take block
20f1ca23e9
2021-02-06 20:45:08 +09:00
aycabta
167dc37632 [ruby/irb] Try not to register the exact same measuring method twice
cc66b5573e
2020-12-24 23:26:22 +09:00
aycabta
0b14abe8e7 [ruby/irb] Suppress "shadowing outer" warning
27b149c599
2020-12-22 23:45:43 +09:00
aycabta
4131cd05be [ruby/irb] Support arg for measure command
b43f35d8f3
2020-12-22 23:45:43 +09:00
aycabta
9f08e3c703 [ruby/irb] Add measure command
You can use "measure" command to check performance in IRB like below:

  irb(main):001:0> 3
  => 3
  irb(main):002:0> measure
  TIME is added.
  => nil
  irb(main):003:0> 3
  processing time: 0.000058s
  => 3
  irb(main):004:0> measure :off
  => nil
  irb(main):005:0> 3
  => 3

You can set "measure :on" by "IRB.conf[:MEASURE] = true" in .irbrc, and, also,
set custom performance check method:

  IRB.conf[:MEASURE_PROC][:CUSTOM] = proc { |context, code, line_no, &block|
    time = Time.now
    result = block.()
    now = Time.now
    puts 'custom processing time: %fs' % (Time.now - time) if IRB.conf[:MEASURE]
    result
  }

3899eaf2e2
2020-12-20 16:23:59 +09:00