Class: Pwrake::GraphTracer
- Inherits:
-
Object
- Object
- Pwrake::GraphTracer
show all
- Defined in:
- lib/pwrake/misc/mcgp.rb
Instance Method Summary
collapse
Constructor Details
#initialize(loc_list, weight_list) ⇒ GraphTracer
Returns a new instance of GraphTracer.
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# 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 = {}
@group_list = @n_part.times.map do |i|
GraphGroup.new(@loc_list[i],@weight_list[i],@vertex_depth,@grviz)
end
end
|
Instance Method Details
#trace(name = "default", target = nil) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# 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]
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)
fsz = tw.file_size
if fsz > 100000
group.push_loc_edge( locs, name, target, fsz/10000 )
end
else
end
return depth
end
group.push_vertex( name )
if tgid == group_id
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) ⇒ Object
122
123
124
|
# File 'lib/pwrake/misc/mcgp.rb', line 122
def write_dot(file)
@grviz.write(file)
end
|