Class: Pik::Benchmark

Inherits:
Ruby show all
Defined in:
lib/pik/commands/run_command.rb

Instance Attribute Summary

Attributes inherited from Command

#config, #debug, #options, #output, #version

Instance Method Summary collapse

Methods inherited from Ruby

#command

Methods inherited from Run

#args_required?, #check_args, #command, #command_options, #echo_ruby_version, #parse_options, #switch_gem_home_to, #switch_path_to

Methods inherited from Command

#actual_gem_home, #add_sigint_handler, aka, choose_from, #close, cmd_name, #cmd_name, #command_options, #create, #current_gem_bin_path, #current_version?, #default_gem_home, #delete_old_pik_script, description, #editors, #find_config_from_path, #gem_path, #get_version, hl, inherited, #initialize, it, names, #parse_options, #pik_version, #sh, summary

Constructor Details

This class inherits a constructor from Pik::Command

Instance Method Details

#benchmark(name, data) ⇒ Object



171
172
173
174
175
176
177
178
179
180
# File 'lib/pik/commands/run_command.rb', line 171

def benchmark(name, data)
bench =<<BM
require "benchmark" 
Benchmark.bmbm do |benchmark| 
  benchmark.report("** benchmarking '#{File.basename(name)}'") do 
#{data}
  end
end
BM
end

#executeObject



160
161
162
163
164
165
166
167
168
169
# File 'lib/pik/commands/run_command.rb', line 160

def execute
  file_name = @args.first
  file_data = File.read(file_name)
    
  Tempfile.open('pik_bench') do |temp|
    @args = [temp.path]
    temp.write benchmark(file_name, file_data)
  end
  super
end

#help_messageObject



182
183
184
185
186
187
188
189
# File 'lib/pik/commands/run_command.rb', line 182

def help_message
  sep =<<SEP
  Examples:

C:\\>pik benchmark hello.rb

SEP
end