class Pwrake::GraphTracer

Public Class Methods

new(loc_list, weight_list) click to toggle source
# File lib/pwrake/misc/mcgp.rb, line 50
def initialize(loc_list, weight_list)
  if loc_list.size != weight_list.size
    raise ArgumentError, "array size of args mismatch"
  end
  @loc_list = loc_list
  @weight_list = weight_list
  @n_part = @loc_list.size
  @traced = {}
  @vertex_depth = {}
  # @grviz = Grviz.new
  @group_list = @n_part.times.map do |i|
    GraphGroup.new(@loc_list[i],@weight_list[i],@vertex_depth,@grviz)
  end
end

Public Instance Methods

trace(name="default", target=nil) click to toggle source
# File lib/pwrake/misc/mcgp.rb, line 65
def trace(name="default", target=nil)

  task = Rake.application[name]
  tw = task.wrapper
  group_id = tw.group_id || 0
  group = @group_list[group_id]
  #loc_list = @loc_list[group_id]
  depth = 0

  if task.class == Rake::FileTask
    tgid = (target) ? (Rake.application[target].wrapper.group_id||0) : nil

    if File.file?(name)
      if tgid == group_id
        locs = get_location(tw)
        #if locs.empty?
        #  Pwrake.application.postprocess(task)
        #  locs = get_location(tw)
        #end
        #tw.get_file_stat
        fsz = tw.file_size
        if fsz > 100000
          #puts "g=#{group_id}, task=#{name}, target=#{target}, fsz=#{fsz}, locs="+locs.join("|")
          group.push_loc_edge( locs, name, target, fsz/10000 )
        end
      else
        #puts "g=#{group_id}, task=#{name}, tgid=#{tgid}, target=#{target}"
      end
      return depth
    end

    group.push_vertex( name )
    if tgid == group_id
      #puts "g=#{group_id}, task=#{name}, target=#{target}"
      group.push_edge( name, target, nil )
    end
    target = name
  end

  if !@traced[name]
    @traced[name] = true

    task.prerequisites.each do |prereq|
      d = trace( prereq, target )
      depth = d if d and d > depth
    end

    if task.class == Rake::FileTask
      depth += 1
    end

    @vertex_depth[name] = depth
  end

  return @vertex_depth[name]
end
write_dot(file) click to toggle source
# File lib/pwrake/misc/mcgp.rb, line 122
def write_dot(file)
  @grviz.write(file)
end