Skip to content

Commit

Permalink
Performance-measuring code - temporary
Browse files Browse the repository at this point in the history
* time() { ... }
* Performane in running rgeom tests is poor; trying to determine why
  * Main bottleneck is all the external requires in rgeom.rb
  • Loading branch information
gsinclair committed Jul 14, 2010
1 parent d5c8579 commit 294df37
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions bin/attest
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env ruby

require 'dev-utils/debug'

def time(task)
time = Time.now
yield
time = Time.now - time
debug "#{task}: #{time}"
end

#time('require rgeom') { require 'rgeom' } # Don't need this here; just timing it.

time('require col') {
require 'col'
}

class AttestRunner
def banner()
Expand Down Expand Up @@ -40,8 +53,10 @@ end

require 'optparse'
require 'ostruct'
time('require attest') {
require 'attest'
class ::Object; include Attest; end
}

END { AttestRunner.new.run }

Expand All @@ -54,7 +69,7 @@ class AttestRunner
def run
parse_options(ARGV) # side-effect: @options
case @options.command
when :run then do_run
when :run then time('do_run') { do_run }
when :list then do_list
when :file then do_file
when :help then do_help
Expand Down Expand Up @@ -131,9 +146,9 @@ class AttestRunner
# do_run, do_example, do_list, do_file, do_help

def do_run
ready
aim
fire!
time('ready') { ready }
time('aim') { aim }
time('fire!') { fire! }
end

def do_list
Expand Down Expand Up @@ -202,7 +217,7 @@ class AttestRunner
def fire!
if @setup_file
vmsg "Running #{@setup_file} first"
load @setup_file
time("load _setup.rb") { load @setup_file }
else
vmsg "No setup file #{@setup_file} to run"
end
Expand All @@ -218,9 +233,9 @@ class AttestRunner
else
@files.each { |file|
vmsg "Loading file: #{file}"
load file
time("load '#{file}'") { load file }
}
Attest.run(attest_options)
time('Attest.run') { Attest.run(attest_options) }
end
end

Expand Down

0 comments on commit 294df37

Please sign in to comment.