Top Level Namespace

Defined Under Namespace

Classes: Array, ArrayOfArrays, ArrayOfHashes, BackLinkedDirectedGraph, BooleanMatrix, DagPropagator, DefaultInitArray, DefaultInitHash, DirectedGraph, DotGraphPrinter, GraphLink, GraphR, GraphTraversalException, HashOfHash

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



413
414
415
416
417
# File 'lib/graphr/directed_graph.rb', line 413

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/graphr/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