slow-actions 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 3
3
- :major: 0
4
2
  :minor: 3
3
+ :patch: 4
4
+ :major: 0
@@ -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
@@ -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
+ User Columns (0.9ms) SHOW FIELDS FROM `users`
5
+ User Indexes (0.2ms) SHOW KEYS FROM `users`
6
+ User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
7
+ Site Load (0.2ms) SELECT id, name FROM `sites` 
8
+ Site Columns (1.0ms) SHOW FIELDS FROM `sites`
9
+ Site Indexes (0.2ms) SHOW KEYS FROM `sites`
10
+ Site Load (0.2ms) SELECT * FROM `sites` WHERE (`sites`.`id` = 8) LIMIT 1
11
+ SuccessfulDonation Load (0.3ms) SELECT * FROM `successful_donations` WHERE (`successful_donations`.`site_id` = 10) ORDER BY created_at ASC
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
+
@@ -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
+
@@ -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.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-07-10 00:00:00 -04:00
12
+ date: 2009-10-20 00:00:00 -04:00
13
13
  default_executable: slow-actions
14
14
  dependencies: []
15
15
 
16
- description: Inspect a rails application's log file to find slow actions
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: Inspect a rails application's log file to find slow actions
72
+ summary: Reads a rails app's log file for slow actions
71
73
  test_files:
72
- - test/slow_actions_benchmark_test.rb
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