Permalink
Browse files

Added top 10 node coloring, include filtering, and minimum edge filte…

…ring
  • Loading branch information...
1 parent 99cd4a7 commit 1ff280a699856781061568fbb9004509fe18780a Ryan Davis committed Aug 1, 2008
Showing with 20 additions and 4 deletions.
  1. +19 −4 rakelib/debug.rake
  2. +1 −0 rakelib/vm.rake
View
@@ -1,20 +1,23 @@
namespace :debug do
desc "Create a dot graph of the Rakefile's dependencies. Use :exclude to exclude rules and dependencies."
- task :graph, :exclude, :filter do |_, args|
+ task :graph, :include, :exclude, :minimum do |_, args|
begin
+ $: << File.expand_path("~/Work/p4/zss/src/ZenHacks/dev/lib/")
require 'graph'
rescue LoadError
abort 'install ZenHacks'
end
- exclude = /#{args[:exclude]}/ if args[:exclude]
+ exclude = Regexp.new(args[:exclude]) if args[:exclude]
+ include = Regexp.new(args[:include]) if args[:exclude]
+ minimum = (args[:minimum] || 0).to_i
graph = Graph.new
- graph.prefix << 'rankdir="LR"'
Rake::Task.tasks.each do |task|
next if task.name =~ /^stats|^vm\/.depends.mf$/ # too many
+ next if include and task.name !~ include
next if exclude and task.name =~ exclude
prereqs = task.prerequisites
@@ -25,7 +28,19 @@ namespace :debug do
graph[task.name] = prereqs
end
- open 'rubinius_tasks.dot', 'w' do |io| io << graph end
+ invert_graph = graph.invert
+ invert_graph.filter_size minimum if minimum > 0
+ invert_graph.prefix << 'rankdir="LR"'
+
+ invert_graph.keys_by_count.first(10).each_with_index do |key, i|
+ if i < 5 then
+ invert_graph.attribs[key] << "color = red"
+ else
+ invert_graph.attribs[key] << "color = orange"
+ end
+ end
+
+ open 'rubinius_tasks.dot', 'w' do |io| io << invert_graph end
end
desc "Display prerequisites for a task"
View
@@ -237,6 +237,7 @@ file dep_file => srcs + hdrs + vm_srcs + generated do |t|
cmd = "makedepend -f- #{includes} -- #{flags} -- #{t.prerequisites}"
cmd << ' 2>/dev/null' unless $verbose
+ warn "makedepend ..."
dep = `#{cmd}`
dep.gsub!(%r% /usr/include\S+%, '') # speeds up rake a lot

0 comments on commit 1ff280a

Please sign in to comment.