dgtized (owner)

Revisions

  • 8e32b7 Tue May 19 14:14:08 -0700 2009
gist: 114409 Download_button fork
public
Public Clone URL: git://gist.github.com/114409.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
diff --git a/kernel/delta/profiler.rb b/kernel/delta/profiler.rb
index b5e641a..bdd4507 100644
--- a/kernel/delta/profiler.rb
+++ b/kernel/delta/profiler.rb
@@ -20,6 +20,7 @@ module Rubinius
       end
 
       def initialize(options = {})
+ @options = { :sort => [:percent] }
         set_options options
         set_options :full_report => true if RUBY_CONFIG["rbx.profiler.full_report"]
         set_options :graph => true if RUBY_CONFIG["rbx.profiler.graph"]
@@ -40,7 +41,6 @@ module Rubinius
       #
       # @todo Add options for GC allocation counts
       def set_options(options)
- @options ||= { :sort => :percent }
         @options.merge!(options)
       end
 
@@ -119,7 +119,10 @@ module Rubinius
             name ]
         end
 
- data = data.sort_by {|row| -row[sort_order.first] }
+ columns = sort_order
+ data = data.sort_by do |row|
+ columns.map {|col| row[col] }
+ end.reverse
 
         out.puts " % cumulative self self total"
         out.puts " time seconds seconds calls ms/call ms/call name"
@@ -242,7 +245,7 @@ module Rubinius
 
       def sort_order
         # call to_i so if unrecognized symbol is passed, column will be percent
- Array(@options[:sort]).map { |header| HEADER_INDEX[header].to_i }
+ @options[:sort].map { |header| HEADER_INDEX[header].to_i }
       end
     end
 
diff --git a/kernel/loader.rb b/kernel/loader.rb
index 32bf474..5f0422d 100644
--- a/kernel/loader.rb
+++ b/kernel/loader.rb
@@ -169,7 +169,7 @@ begin
       require 'profile'
     when /^-P\w/
       require 'profile'
- Profiler__.options :sort => arg[2..-1].to_sym
+ Profiler__.options :sort => arg[2..-1].split(/,/).map {|x| x.to_sym }
     when '-gc'
       stats = Rubinius::Stats::GC.new
       at_exit { stats.show }