module Benchmarker
$Release: 1.0.0 $ $Copyright: copyright© 2010-2021 kuwata-lab.com all rights reserved $ $License: MIT License $
Constants
- N_REPEAT
- OPTIONS
- TASK
- TimeSet
- VERSION
Public Class Methods
new(title=nil, **kwargs, &b)
click to toggle source
# File lib/benchmarker.rb, line 19 def self.new(title=nil, **kwargs, &b) #; [!s7y6x] overwrites existing options by command-line options. kwargs.update(OPTIONS) #; [!2zh7w] creates new Benchmark object wit options. bm = Benchmark.new(title: title, **kwargs) return bm end
parse_cmdopts(argv=ARGV)
click to toggle source
# File lib/benchmarker.rb, line 958 def self.parse_cmdopts(argv=ARGV) #; [!348ip] parses command-line options. #; [!snqxo] exits with status code 1 if error in command option. options, keyvals = OptionParser.parse_options(argv) do |errmsg| $stderr.puts errmsg exit 1 end #; [!p3b93] prints help message if '-h' or '--help' option specified. if options['h'] || keyvals['help'] puts OptionParser.help_message() exit 0 end #; [!iaryj] prints version number if '-v' option specified. if options['v'] puts VERSION exit 0 end #; [!nrxsb] prints sample code if '-S' option specified. if options['S'] puts Misc.sample_code() exit 0 end #; [!s7y6x] keeps command-line options in order to overwirte existing options. #; [!nexi8] option '-w' specifies task name width. #; [!raki9] option '-n' specifies count of loop. #; [!mt7lw] option '-i' specifies number of iteration. #; [!7f2k3] option '-x' specifies number of best/worst tasks removed. #; [!r0439] option '-I' specifies inverse switch. #; [!4c73x] option '-o' specifies outout JSON file. #; [!02ml5] option '-q' specifies quiet mode. #; [!e5hv0] option '-c' specifies colorize enabled. #; [!eb5ck] option '-C' specifies colorize disabled. #; [!6nxi8] option '-s' specifies sleep time. #; [!muica] option '-F' specifies filter. OPTIONS[:width] = options['w'] if options['w'] OPTIONS[:loop] = options['n'] if options['n'] OPTIONS[:iter] = options['i'] if options['i'] OPTIONS[:extra] = options['x'] if options['x'] OPTIONS[:inverse] = options['I'] if options['I'] OPTIONS[:outfile] = options['o'] if options['o'] OPTIONS[:quiet] = options['q'] if options['q'] OPTIONS[:colorize] = true if options['c'] OPTIONS[:colorize] = false if options['C'] OPTIONS[:sleep] = options['s'] if options['s'] OPTIONS[:filter] = options['F'] if options['F'] #; [!3khc4] sets global variables if long option specified. keyvals.each {|k, v| eval "$opt_#{k} = #{v.inspect}" } # return options, keyvals # for testing end
scope(title=nil, **kwargs, &block)
click to toggle source
# File lib/benchmarker.rb, line 27 def self.scope(title=nil, **kwargs, &block) #; [!4f695] creates Benchmark object, define tasks, and run them. bm = self.new(title, **kwargs) bm.scope(&block) bm.run() return bm end