slow-actions 0.3.3 → 0.3.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/README.rdoc +6 -0
- data/VERSION.yml +2 -2
- data/lib/slow_actions/slow_actions_parser.rb +9 -0
- data/test/data/new.log +14 -0
- data/test/data/old.log +8 -0
- data/test/slow_actions_test.rb +24 -0
- metadata +8 -6
data/README.rdoc
CHANGED
@@ -4,6 +4,12 @@ Nick Gauthier (nick@smartlogicsolutions.com)
|
|
4
4
|
== Description
|
5
5
|
Reads a rails app's log file for slow actions
|
6
6
|
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
You will need to have Gemcutter[http://gemcutter.org/] in your list of gem sources.
|
10
|
+
|
11
|
+
gem install slow-actions
|
12
|
+
|
7
13
|
== Usage
|
8
14
|
|
9
15
|
=== Command line
|
data/VERSION.yml
CHANGED
@@ -73,14 +73,23 @@ class SlowActions
|
|
73
73
|
end
|
74
74
|
if line =~ /^Completed in (\S+)/
|
75
75
|
la.duration = $1.to_f
|
76
|
+
if $1[-2,2] != "ms"
|
77
|
+
la.duration *= 1000.0
|
78
|
+
end
|
76
79
|
end
|
77
80
|
if line =~ /Rendering: (\S+)/
|
78
81
|
la.rendering = $1.to_f
|
82
|
+
if $1[-2,2] != "ms"
|
83
|
+
la.rendering *= 1000.0
|
84
|
+
end
|
79
85
|
else
|
80
86
|
la.rendering = 0.0
|
81
87
|
end
|
82
88
|
if line =~ /DB: (\S+)/
|
83
89
|
la.db = $1.to_f
|
90
|
+
if $1[-2,2] != "ms"
|
91
|
+
la.db *= 1000.0
|
92
|
+
end
|
84
93
|
else
|
85
94
|
la.db = 0.0
|
86
95
|
end
|
data/test/data/new.log
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
Processing Admin::DonationsController#filter_by_site (for 127.0.0.1 at 2009-10-09 15:43:46) [POST]
|
3
|
+
Parameters: {"authenticity_token"=>"j/Lm+X6E4JtsmMhpJcpFsceEaSWa1AJ7L9eRJM+7iUw=", "page"=>"", "_"=>"", "site_id"=>"10"}
|
4
|
+
[4;36;1mUser Columns (0.9ms)[0m [0;1mSHOW FIELDS FROM `users`[0m
|
5
|
+
[4;35;1mUser Indexes (0.2ms)[0m [0mSHOW KEYS FROM `users`[0m
|
6
|
+
[4;36;1mUser Load (0.2ms)[0m [0;1mSELECT * FROM `users` WHERE (`users`.`id` = 3) LIMIT 1[0m
|
7
|
+
[4;35;1mSite Load (0.2ms)[0m [0mSELECT id, name FROM `sites` [0m
|
8
|
+
[4;36;1mSite Columns (1.0ms)[0m [0;1mSHOW FIELDS FROM `sites`[0m
|
9
|
+
[4;35;1mSite Indexes (0.2ms)[0m [0mSHOW KEYS FROM `sites`[0m
|
10
|
+
[4;36;1mSite Load (0.2ms)[0m [0;1mSELECT * FROM `sites` WHERE (`sites`.`id` = 8) LIMIT 1[0m
|
11
|
+
[4;35;1mSuccessfulDonation Load (0.3ms)[0m [0mSELECT * FROM `successful_donations` WHERE (`successful_donations`.`site_id` = 10) ORDER BY created_at ASC[0m
|
12
|
+
Rendered admin/donations/_donation_table (0.4ms)
|
13
|
+
Completed in 191ms (View: 2, DB: 4) | 200 OK [http://cms.psl.localhost/admin/donations/filter_by_site]
|
14
|
+
|
data/test/data/old.log
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
Processing ClientsController#show (for 127.0.0.1 at 2008-04-09 15:26:51) [GET]
|
3
|
+
Session ID: 95319ed68ddb58d38038d6381611bc5f
|
4
|
+
Parameters: {"action"=>"show", "id"=>"1", "controller"=>"vendor/clients"}
|
5
|
+
Redirected to http://www.example.com/vendor/login
|
6
|
+
Filter chain halted as [#<ActionController::Filters::ClassMethods::SymbolFilter:0x7f4d31674eb0 @filter=:check_authentication>] rendered_or_redirected.
|
7
|
+
Completed in 0.00034 (2949 reqs/sec) | DB: 0.00079 (232%) | 302 Found [http://www.example.com/vendor/clients/1]
|
8
|
+
|
data/test/slow_actions_test.rb
CHANGED
@@ -80,4 +80,28 @@ class SlowActionsTest < Test::Unit::TestCase
|
|
80
80
|
assert_equal 3, @sa.log_entries.size
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
context "When parsing an old Rails log file with time in seconds" do
|
85
|
+
setup do
|
86
|
+
@log_file = File.join(File.dirname(__FILE__), 'data', 'old.log')
|
87
|
+
@sa = SlowActions.new
|
88
|
+
@sa.parse_file(@log_file)
|
89
|
+
end
|
90
|
+
|
91
|
+
should "convert the time to milliseconds" do
|
92
|
+
assert_equal 0.34, @sa.log_entries.first.duration
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "When parsing a new Rails log file with time in milliseconds" do
|
97
|
+
setup do
|
98
|
+
@log_file = File.join(File.dirname(__FILE__), 'data', 'new.log')
|
99
|
+
@sa = SlowActions.new
|
100
|
+
@sa.parse_file(@log_file)
|
101
|
+
end
|
102
|
+
|
103
|
+
should "leave the time in milliseconds" do
|
104
|
+
assert_equal 191.0, @sa.log_entries.first.duration
|
105
|
+
end
|
106
|
+
end
|
83
107
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slow-actions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Gauthier
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-20 00:00:00 -04:00
|
13
13
|
default_executable: slow-actions
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: Reads a rails app's log file for slow actions
|
17
17
|
email: nick@smartlogicsolutions.com
|
18
18
|
executables:
|
19
19
|
- slow-actions
|
@@ -34,6 +34,8 @@ files:
|
|
34
34
|
- lib/slow_actions/slow_actions_parser.rb
|
35
35
|
- lib/slow_actions/slow_actions_session.rb
|
36
36
|
- test/data/development.log
|
37
|
+
- test/data/new.log
|
38
|
+
- test/data/old.log
|
37
39
|
- test/data/production.recent.log
|
38
40
|
- test/slow_actions_benchmark_test.rb
|
39
41
|
- test/slow_actions_parser_test.rb
|
@@ -67,9 +69,9 @@ rubyforge_project:
|
|
67
69
|
rubygems_version: 1.3.5
|
68
70
|
signing_key:
|
69
71
|
specification_version: 3
|
70
|
-
summary:
|
72
|
+
summary: Reads a rails app's log file for slow actions
|
71
73
|
test_files:
|
72
|
-
- test/
|
74
|
+
- test/test_helper.rb
|
73
75
|
- test/slow_actions_parser_test.rb
|
76
|
+
- test/slow_actions_benchmark_test.rb
|
74
77
|
- test/slow_actions_test.rb
|
75
|
-
- test/test_helper.rb
|