ngauthier-slow-actions 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/bin/slow-actions +22 -6
- data/lib/slow_actions.rb +19 -16
- metadata +1 -1
data/VERSION.yml
CHANGED
data/bin/slow-actions
CHANGED
@@ -1,10 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'slow_actions')
|
3
|
+
|
3
4
|
@sa = SlowActions.new
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
ARGV.select{|arg| arg[0,2] != "--"}.each do |file|
|
6
|
+
@sa.parse_file(file)
|
7
|
+
end
|
8
|
+
|
9
|
+
output = []
|
10
|
+
if (ARGV.include? "--actions")
|
11
|
+
output << @sa.print_actions
|
12
|
+
end
|
13
|
+
if (ARGV.include? "--controllers")
|
14
|
+
output << @sa.print_controller_tree
|
15
|
+
end
|
16
|
+
if (ARGV.include? "--sessions")
|
17
|
+
output << @sa.print_sessions
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
if output.size == 0
|
22
|
+
puts "Usage: slow-actions (--actions | --controllers | --sessions) log_file"
|
23
|
+
else
|
24
|
+
puts output.join("\n\n")
|
25
|
+
end
|
10
26
|
|
data/lib/slow_actions.rb
CHANGED
@@ -20,13 +20,13 @@ class SlowActions
|
|
20
20
|
|
21
21
|
def print_actions
|
22
22
|
str = ""
|
23
|
-
str += " Cost
|
23
|
+
str += " Cost Average Max\n"
|
24
24
|
actions.sort{|x,y| y.total_cost <=> x.total_cost}.each do |a|
|
25
|
-
str += "
|
25
|
+
str += "- #{a.controller.name} : #{a.name} (#{a.log_entries.size} entries)\n"
|
26
26
|
str += " Total: #{ftos a.total_cost}#{ftos a.total_avg}#{ftos a.total_max}\n"
|
27
27
|
str += " Render: #{ftos a.render_cost}#{ftos a.render_avg}#{ftos a.render_max}\n"
|
28
28
|
str += " DB: #{ftos a.db_cost}#{ftos a.db_avg}#{ftos a.db_max}\n"
|
29
|
-
|
29
|
+
str += "\n"
|
30
30
|
end
|
31
31
|
return str
|
32
32
|
end
|
@@ -35,28 +35,30 @@ class SlowActions
|
|
35
35
|
str = ""
|
36
36
|
str += " Cost Average Max\n"
|
37
37
|
controllers.sort{|x,y| y.total_cost <=> x.total_cost}.each do |c|
|
38
|
-
str += "
|
39
|
-
str += "
|
40
|
-
str += "
|
41
|
-
str += "
|
38
|
+
str += "+ #{c.name} (#{c.log_entries.size} entries)\n"
|
39
|
+
str += "| Total: #{ftos c.total_cost}#{ftos c.total_avg}#{ftos c.total_max}\n"
|
40
|
+
str += "| Render: #{ftos c.render_cost}#{ftos c.render_avg}#{ftos c.render_max}\n"
|
41
|
+
str += "| DB: #{ftos c.db_cost}#{ftos c.db_avg}#{ftos c.db_max}\n"
|
42
42
|
c.actions.sort{|x,y| y.total_cost <=> x.total_cost}.each do |a|
|
43
|
-
str += "
|
44
|
-
str += "
|
45
|
-
str += "
|
46
|
-
str += "
|
43
|
+
str += "|-+ #{a.name} (#{a.log_entries.size} entries)\n"
|
44
|
+
str += "| | Total: #{ftos a.total_cost}#{ftos a.total_avg}#{ftos a.total_max}\n"
|
45
|
+
str += "| | Render: #{ftos a.render_cost}#{ftos a.render_avg}#{ftos a.render_max}\n"
|
46
|
+
str += "| | DB: #{ftos a.db_cost}#{ftos a.db_avg}#{ftos a.db_max}\n"
|
47
47
|
end
|
48
|
+
str += "\n"
|
48
49
|
end
|
49
50
|
return str
|
50
51
|
end
|
51
52
|
|
52
53
|
def print_sessions
|
53
54
|
str = ""
|
54
|
-
str += " Cost
|
55
|
+
str += " Cost Average Max\n"
|
55
56
|
sessions.sort{|x,y| y.total_cost <=> x.total_cost}.each do |s|
|
56
|
-
str += "
|
57
|
-
str += "
|
58
|
-
str += "
|
59
|
-
str += "
|
57
|
+
str += "+ #{s.name} (#{s.log_entries.size} entries)\n"
|
58
|
+
str += "| Total: #{ftos s.total_cost}#{ftos s.total_avg}#{ftos s.total_max}\n"
|
59
|
+
str += "| Render: #{ftos s.render_cost}#{ftos s.render_avg}#{ftos s.render_max}\n"
|
60
|
+
str += "| DB: #{ftos s.db_cost}#{ftos s.db_avg}#{ftos s.db_max}\n"
|
61
|
+
str += "\n"
|
60
62
|
end
|
61
63
|
return str
|
62
64
|
end
|
@@ -106,6 +108,7 @@ class SlowActions
|
|
106
108
|
@sessions[la.session] = s
|
107
109
|
end
|
108
110
|
s.add_entry(la)
|
111
|
+
la.processed = true
|
109
112
|
end
|
110
113
|
|
111
114
|
# now compute the times for each
|