Class: Bullshit::CaseMethod
- Inherits:
-
Struct
- Object
- Struct
- Bullshit::CaseMethod
- Defined in:
- lib/bullshit.rb,
lib/bullshit.rb
Overview
This class’ instance represents a method to be benchmarked.
Instance Attribute Summary collapse
-
#case ⇒ Object
Returns the value of attribute case.
-
#clock ⇒ Object
Returns the value of attribute clock.
-
#comment ⇒ Object
The comment for this method.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#after_name ⇒ Object
Return the after_name, e.
-
#after_run ⇒ Object
Call after method of this CaseMethod after benchmarking it.
-
#before_name ⇒ Object
Return the before_name, e.
-
#before_run ⇒ Object
Call before method of this CaseMethod before benchmarking it.
-
#cover?(other) ⇒ Boolean
Return true if this CaseMethod#clock covers other.clock.
-
#file_path(type = nil, suffix = '.dat') ⇒ Object
Return the file name for
type
withsuffix
(if any) for this clock. -
#load(fp = file_path) ⇒ Object
Load the data of file
fp
into this clock. -
#long_name ⇒ Object
Returns the long_name of this CaseMethod of the form Foo#bar.
-
#setup_name ⇒ Object
Return the setup_name, e.
-
#short_name ⇒ Object
Return the short name of this CaseMethod instance, that is without the “benchmark_” prefix, e.
-
#teardown_name ⇒ Object
Return the teardown_name, e.
Instance Attribute Details
#case ⇒ Object
Returns the value of attribute case
1367 1368 1369 |
# File 'lib/bullshit.rb', line 1367 def case @case end |
#clock ⇒ Object
Returns the value of attribute clock
1367 1368 1369 |
# File 'lib/bullshit.rb', line 1367 def clock @clock end |
#comment ⇒ Object
The comment for this method.
1378 1379 1380 |
# File 'lib/bullshit.rb', line 1378 def comment @comment end |
#name ⇒ Object
Returns the value of attribute name
1367 1368 1369 |
# File 'lib/bullshit.rb', line 1367 def name @name end |
Instance Method Details
#after_name ⇒ Object
Return the after_name, e. g. “after_foo”.
1398 1399 1400 |
# File 'lib/bullshit.rb', line 1398 def after_name 'after_' + short_name end |
#after_run ⇒ Object
Call after method of this CaseMethod after benchmarking it.
1421 1422 1423 1424 1425 1426 |
# File 'lib/bullshit.rb', line 1421 def after_run if self.case.respond_to? after_name $DEBUG and warn "Calling #{after_name}." self.case.__send__(after_name) end end |
#before_name ⇒ Object
Return the before_name, e. g. “before_foo”.
1393 1394 1395 |
# File 'lib/bullshit.rb', line 1393 def before_name 'before_' + short_name end |
#before_run ⇒ Object
Call before method of this CaseMethod before benchmarking it.
1413 1414 1415 1416 1417 1418 |
# File 'lib/bullshit.rb', line 1413 def before_run if self.case.respond_to? before_name $DEBUG and warn "Calling #{before_name}." self.case.__send__(before_name) end end |
#cover?(other) ⇒ Boolean
Return true if this CaseMethod#clock covers other.clock.
1408 1409 1410 |
# File 'lib/bullshit.rb', line 1408 def cover?(other) clock.cover?(other.clock) end |
#file_path(type = nil, suffix = '.dat') ⇒ Object
Return the file name for type
with suffix
(if any) for this clock.
1429 1430 1431 1432 1433 1434 1435 |
# File 'lib/bullshit.rb', line 1429 def file_path(type = nil, suffix = '.dat') name = self.case.class.benchmark_name.dup name << '#' << short_name type and name << '-' << type name << suffix File.(name, self.case.class.output_dir) end |
#load(fp = file_path) ⇒ Object
Load the data of file fp
into this clock.
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 |
# File 'lib/bullshit.rb', line 1438 def load(fp = file_path) self.clock = self.case.class.clock.new self $DEBUG and warn "Loading '#{fp}' into clock." File.open(fp, 'r') do |f| f.each do |line| line.chomp! line =~ /^\s*#/ and next clock << line.split(/\t/) end end self end |
#long_name ⇒ Object
Returns the long_name of this CaseMethod of the form Foo#bar.
1381 1382 1383 1384 1385 |
# File 'lib/bullshit.rb', line 1381 def long_name result = "#{self.case}##{short_name}" result = "#{result} (#{comment})" if comment result end |
#setup_name ⇒ Object
Return the setup_name, e. g. “setup_foo”.
1388 1389 1390 |
# File 'lib/bullshit.rb', line 1388 def setup_name 'setup_' + short_name end |
#short_name ⇒ Object
Return the short name of this CaseMethod instance, that is without the “benchmark_” prefix, e. g. “foo”.
1373 1374 1375 |
# File 'lib/bullshit.rb', line 1373 def short_name @short_name ||= name.sub(/\Abenchmark_/, '') end |
#teardown_name ⇒ Object
Return the teardown_name, e. g. “teardown_foo”.
1403 1404 1405 |
# File 'lib/bullshit.rb', line 1403 def teardown_name 'teardown_' + short_name end |