Top Level Namespace

Defined Under Namespace

Modules: FSM, Kernel Classes: Array, ArrayOfArrays, ArrayOfHashes, BackLinkedDirectedGraph, BooleanMatrix, DagPropagator, DefaultInitArray, DefaultInitHash, DirectedGraph, DotGraphPrinter, GraphLink, GraphTraversalException, HashOfHash, Thread

Constant Summary collapse

TimesClass =
(RUBY_VERSION < "1.7") ? Time : Process

Instance Method Summary collapse

Instance Method Details

#calc_masks(start, stop, masks = Array.new) ⇒ Object


421
422
423
424
425
# File 'lib/fsm-0.0.0/graph/directed_graph.rb', line 421

def calc_masks(start, stop, masks = Array.new)
  mask = 1 << start
  (start..stop).each {|i| masks[i] = mask; mask <<= 1}
  masks
end

#time_and_puts(string, &block) ⇒ Object


57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fsm-0.0.0/graph/base_extensions.rb', line 57

def time_and_puts(string, &block)
  if $TIME_AND_PUTS_VERBOSE
    print string; STDOUT.flush
  end
  starttime = [Time.new, TimesClass.times]
  block.call
  endtime = [Time.new, TimesClass.times] 
  duration = endtime[0] - starttime[0]
  begin
    load = [((endtime[1].utime+endtime[1].stime)-(starttime[1].utime+starttime[1].stime))/duration*100.0, 100.0].min
    puts " (%.2f s %.2f%%)" % [duration, load] if $TIME_AND_PUTS_VERBOSE
  rescue FloatDomainError
  end
end