ngauthier-slow-actions 0.3.2 → 0.3.3
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/README.rdoc +51 -31
- data/VERSION.yml +1 -1
- data/lib/slow_actions.rb +8 -4
- data/lib/slow_actions_computation_module.rb +3 -3
- data/lib/slow_actions_log_entry.rb +1 -2
- data/lib/slow_actions_parser.rb +3 -3
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -25,36 +25,56 @@ Reads a rails app's log file for slow actions
|
|
25
25
|
puts @sa.print_actions
|
26
26
|
|
27
27
|
== Sample output:
|
28
|
-
$> slow-actions --
|
28
|
+
$> slow-actions --actions --min-cost=2 test/data/development.log
|
29
|
+
Cost Average Max
|
30
|
+
- UsersController : game_history (22 entries, 0% Error)
|
31
|
+
Total: 11275.447 3642.437 12728.0
|
32
|
+
Render: 7.20300 2.32700 17.2450
|
33
|
+
DB: 10.5020 3.39200 10.0000
|
34
|
+
|
35
|
+
- QuestionsController : refresh_index_table (89 entries, 0% Error)
|
36
|
+
Total: 908.494 202.348 307.000
|
37
|
+
Render: 0.00000 0.00000 0.00000
|
38
|
+
DB: 32.5880 7.25800 10.0000
|
39
|
+
|
40
|
+
- UsersController : show (128 entries, 0% Error)
|
41
|
+
Total: 664.292 136.888 2680.00
|
42
|
+
Render: 0.33500 0.06900 3.41000
|
43
|
+
DB: 18.2330 3.75700 114.000
|
44
|
+
|
45
|
+
$> slow-actions --controllers --min-cost=2 test/data/development.log > ~/Desktop/sa-controllers.txt
|
29
46
|
Cost Average Max
|
30
|
-
+ UsersController (
|
31
|
-
| Total:
|
32
|
-
| Render: 1.
|
33
|
-
| DB:
|
34
|
-
|-+
|
35
|
-
| | Total:
|
36
|
-
| | Render:
|
37
|
-
| | DB:
|
38
|
-
|-+
|
39
|
-
| | Total:
|
40
|
-
| | Render: 0.
|
41
|
-
| | DB:
|
42
|
-
|
43
|
-
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
|
56
|
-
|
57
|
-
|
|
58
|
-
|
59
|
-
|
47
|
+
+ UsersController (236 entries, 0% Error)
|
48
|
+
| Total: 2165.375 396.279 12728.0
|
49
|
+
| Render: 1.63400 0.29900 17.2450
|
50
|
+
| DB: 7.03400 1.28700 114.000
|
51
|
+
|-+ game_history (22 entries, 0% Error)
|
52
|
+
| | Total: 11275.447 3642.437 12728.0
|
53
|
+
| | Render: 7.20300 2.32700 17.2450
|
54
|
+
| | DB: 10.5020 3.39200 10.0000
|
55
|
+
|-+ show (128 entries, 0% Error)
|
56
|
+
| | Total: 664.292 136.888 2680.00
|
57
|
+
| | Render: 0.33500 0.06900 3.41000
|
58
|
+
| | DB: 18.2330 3.75700 114.000
|
59
|
+
|-+ index (812 entries, 51% Error)
|
60
|
+
| | Total: 465.660 69.5050 1922.00
|
61
|
+
| | Render: 0.30100 0.04500 2.39600
|
62
|
+
| | DB: 40.9320 6.10900 1164.00
|
63
|
+
|
64
|
+
$> slow-actions --sessions --min-cost=2 test/data/development.log > ~/Desktop/sa-sessions.txt
|
65
|
+
Cost Average Max
|
66
|
+
+ d2dac54dc3816195ed9ef083e2811c61 (89 entries, 60% Error)
|
67
|
+
| Total: 10923.296 2432.935 12603.0
|
68
|
+
| Render: 0.00000 0.00000 0.00000
|
69
|
+
| DB: 51.9520 11.5710 53.0000
|
70
|
+
|
71
|
+
+ 3283ca1f8b1039f8c4403cbc7f9941c9 (18 entries, 5% Error)
|
72
|
+
| Total: 2179.158 752.494 12728.0
|
73
|
+
| Render: 9.70500 3.35100 17.2450
|
74
|
+
| DB: 2.93100 1.01200 10.0000
|
75
|
+
|
76
|
+
+ 867bc340e6d65e673f29c57189feaf2b (133 entries, 0% Error)
|
77
|
+
| Total: 1083.138 221.450 386.000
|
78
|
+
| Render: 0.00000 0.00000 0.00000
|
79
|
+
| DB: 44.2030 9.03700 90.0000
|
60
80
|
|
data/VERSION.yml
CHANGED
data/lib/slow_actions.rb
CHANGED
@@ -46,7 +46,8 @@ class SlowActions
|
|
46
46
|
next if opts[:mincost] and a.total_cost < opts[:mincost]
|
47
47
|
next if opts[:minavg] and a.total_avg < opts[:minavg]
|
48
48
|
next if opts[:minmax] and a.total_max < opts[:minmax]
|
49
|
-
str += "- #{a.controller.name} : #{a.name}
|
49
|
+
str += "- #{a.controller.name} : #{a.name} "
|
50
|
+
str += "(#{a.log_entries.size} entries, #{(a.error_avg*100).to_i}% Error)\n"
|
50
51
|
str += " Total: #{ftos a.total_cost}#{ftos a.total_avg}#{ftos a.total_max}\n"
|
51
52
|
str += " Render: #{ftos a.render_cost}#{ftos a.render_avg}#{ftos a.render_max}\n"
|
52
53
|
str += " DB: #{ftos a.db_cost}#{ftos a.db_avg}#{ftos a.db_max}\n"
|
@@ -63,7 +64,7 @@ class SlowActions
|
|
63
64
|
next if opts[:mincost] and c.total_cost < opts[:mincost]
|
64
65
|
next if opts[:minavg] and c.total_avg < opts[:minavg]
|
65
66
|
next if opts[:minmax] and c.total_max < opts[:minmax]
|
66
|
-
str += "+ #{c.name} (#{c.log_entries.size} entries)\n"
|
67
|
+
str += "+ #{c.name} (#{c.log_entries.size} entries, #{(c.error_avg*100).to_i}% Error)\n"
|
67
68
|
str += "| Total: #{ftos c.total_cost}#{ftos c.total_avg}#{ftos c.total_max}\n"
|
68
69
|
str += "| Render: #{ftos c.render_cost}#{ftos c.render_avg}#{ftos c.render_max}\n"
|
69
70
|
str += "| DB: #{ftos c.db_cost}#{ftos c.db_avg}#{ftos c.db_max}\n"
|
@@ -71,7 +72,7 @@ class SlowActions
|
|
71
72
|
next if opts[:mincost] and a.total_cost < opts[:mincost]
|
72
73
|
next if opts[:minavg] and a.total_avg < opts[:minavg]
|
73
74
|
next if opts[:minmax] and a.total_max < opts[:minmax]
|
74
|
-
str += "|-+ #{a.name} (#{a.log_entries.size} entries)\n"
|
75
|
+
str += "|-+ #{a.name} (#{a.log_entries.size} entries, #{(a.error_avg*100).to_i}% Error)\n"
|
75
76
|
str += "| | Total: #{ftos a.total_cost}#{ftos a.total_avg}#{ftos a.total_max}\n"
|
76
77
|
str += "| | Render: #{ftos a.render_cost}#{ftos a.render_avg}#{ftos a.render_max}\n"
|
77
78
|
str += "| | DB: #{ftos a.db_cost}#{ftos a.db_avg}#{ftos a.db_max}\n"
|
@@ -89,7 +90,7 @@ class SlowActions
|
|
89
90
|
next if opts[:mincost] and s.total_cost < opts[:mincost]
|
90
91
|
next if opts[:minavg] and s.total_avg < opts[:minavg]
|
91
92
|
next if opts[:minmax] and s.total_max < opts[:minmax]
|
92
|
-
str += "+ #{s.name} (#{s.log_entries.size} entries)\n"
|
93
|
+
str += "+ #{s.name} (#{s.log_entries.size} entries, #{(s.error_avg*100).to_i}% Error)\n"
|
93
94
|
str += "| Total: #{ftos s.total_cost}#{ftos s.total_avg}#{ftos s.total_max}\n"
|
94
95
|
str += "| Render: #{ftos s.render_cost}#{ftos s.render_avg}#{ftos s.render_max}\n"
|
95
96
|
str += "| DB: #{ftos s.db_cost}#{ftos s.db_avg}#{ftos s.db_max}\n"
|
@@ -160,6 +161,9 @@ class SlowActions
|
|
160
161
|
@controllers.values.each{|c| c.compute_times}
|
161
162
|
@actions.values.each{|a| a.compute_times}
|
162
163
|
@sessions.values.each{|s| s.compute_times}
|
164
|
+
|
165
|
+
# return something simple. This helps irb not barf on itself trying to print everything
|
166
|
+
return true
|
163
167
|
end
|
164
168
|
|
165
169
|
# Convert a float to 7 places padded with zeros then one space
|
@@ -49,9 +49,9 @@ module Computable
|
|
49
49
|
@total_max = la.duration if la.duration > @total_max
|
50
50
|
end
|
51
51
|
|
52
|
-
@render_avg /= @log_entries.size.to_f
|
53
|
-
@db_avg /= @log_entries.size.to_f
|
54
|
-
@total_avg /= @log_entries.size.to_f
|
52
|
+
@render_avg /= @log_entries.size.to_f - @error_avg + 0.0001
|
53
|
+
@db_avg /= @log_entries.size.to_f - @error_avg + 0.0001
|
54
|
+
@total_avg /= @log_entries.size.to_f - @error_avg + 0.0001
|
55
55
|
@error_avg /= @log_entries.size.to_f
|
56
56
|
|
57
57
|
# using math.log allows us to smooth out the score between
|
data/lib/slow_actions_parser.rb
CHANGED
@@ -89,12 +89,12 @@ class SlowActions
|
|
89
89
|
while line == "\n"
|
90
90
|
line = @file.readline
|
91
91
|
end
|
92
|
-
error_txt =
|
92
|
+
error_txt = []
|
93
93
|
while line != "\n"
|
94
94
|
line = @file.readline
|
95
|
-
error_txt
|
95
|
+
error_txt.push line
|
96
96
|
end
|
97
|
-
return error_txt
|
97
|
+
return error_txt.join("")
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|