stopwatch 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +73 -0
- data/lib/stopwatch.rb +2 -2
- data/lib/stopwatch/version.rb +1 -1
- data/stopwatch.gemspec +2 -2
- data/stopwatch.png +0 -0
- metadata +10 -9
- data/README.rdoc +0 -20
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Stopwatch
|
2
|
+
|
3
|
+
Show the time that was necessary to render your page and the amount of queries that were executed.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Just add the following to your __development__ group and you are good to go:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem 'stopwatch'
|
11
|
+
```
|
12
|
+
|
13
|
+
Every page will now display the duration in the upper right corner and the
|
14
|
+
amount of (non-cached) queries.
|
15
|
+
|
16
|
+
![Stopwatch in action](https://github.com/bittersweet/stopwatch/raw/master/stopwatch.png)
|
17
|
+
|
18
|
+
## Inspiration
|
19
|
+
|
20
|
+
I was inspired by an article on the [Coding Horror
|
21
|
+
blog](http://www.codinghorror.com/blog/2011/06/performance-is-a-feature.html)
|
22
|
+
where they talk about how adding a small box that displays page speed motivated
|
23
|
+
them to not forget about the performance of their pages.
|
24
|
+
|
25
|
+
Some excerpts:
|
26
|
+
|
27
|
+
> The simple act of putting a render time in the upper right hand corner of
|
28
|
+
> every page we serve forced us to fix all our performance regressions and
|
29
|
+
> omissions.
|
30
|
+
|
31
|
+
> In fact, with the render time appearing on every page for everyone on the dev
|
32
|
+
> team, performance became a point of pride. We had so many places where we had
|
33
|
+
> just gotten a little sloppy or missed some tiny thing that slowed a page down
|
34
|
+
> inordinately.
|
35
|
+
|
36
|
+
I could especially identify with the last one and I wanted to quickly get this
|
37
|
+
gem out there to see if I could recreate that same effect.
|
38
|
+
|
39
|
+
## Caveats
|
40
|
+
|
41
|
+
* It removes etags so we can display it fresh every page load, otherwise the
|
42
|
+
response would get cached by the browser because Rails would return a 304 Not
|
43
|
+
Modified and you wouldn't see any changes on page refresh.
|
44
|
+
|
45
|
+
## Todo
|
46
|
+
|
47
|
+
* Basic configuration
|
48
|
+
|
49
|
+
## Thanks
|
50
|
+
|
51
|
+
[Paul Engel](https://github.com/archan937) For the name!
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
Copyright (C) 2011 by Mark Mulder
|
56
|
+
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
58
|
+
of this software and associated documentation files (the "Software"), to deal
|
59
|
+
in the Software without restriction, including without limitation the rights
|
60
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
61
|
+
copies of the Software, and to permit persons to whom the Software is
|
62
|
+
furnished to do so, subject to the following conditions:
|
63
|
+
|
64
|
+
The above copyright notice and this permission notice shall be included in
|
65
|
+
all copies or substantial portions of the Software.
|
66
|
+
|
67
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
68
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
69
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
70
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
71
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
72
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
73
|
+
THE SOFTWARE.
|
data/lib/stopwatch.rb
CHANGED
@@ -14,8 +14,8 @@ module Stopwatch
|
|
14
14
|
StopwatchLog.event = ActiveSupport::Notifications::Event.new(*args)
|
15
15
|
end
|
16
16
|
|
17
|
-
ActiveSupport::Notifications.subscribe "sql.active_record" do
|
18
|
-
StopwatchLog.increment_query_count
|
17
|
+
ActiveSupport::Notifications.subscribe "sql.active_record" do |name, start, finish, id, payload|
|
18
|
+
StopwatchLog.increment_query_count if payload[:name] != "CACHE"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/stopwatch/version.rb
CHANGED
data/stopwatch.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Mark Mulder"]
|
10
10
|
s.email = ["markmulder@gmail.com"]
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/bittersweet/stopwatch"
|
12
12
|
s.summary = "Show the page load duration."
|
13
|
-
s.description = "This gem uses Rack middleware and the Rails 3
|
13
|
+
s.description = "This gem uses Rack middleware and the Rails 3 Notification API to display page load time and amount of queries executed."
|
14
14
|
|
15
15
|
s.rubyforge_project = "stopwatch"
|
16
16
|
|
data/stopwatch.png
ADDED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stopwatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mark Mulder
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-24 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: This gem uses Rack middleware and the Rails 3
|
22
|
+
description: This gem uses Rack middleware and the Rails 3 Notification API to display page load time and amount of queries executed.
|
23
23
|
email:
|
24
24
|
- markmulder@gmail.com
|
25
25
|
executables: []
|
@@ -31,15 +31,16 @@ extra_rdoc_files: []
|
|
31
31
|
files:
|
32
32
|
- .gitignore
|
33
33
|
- Gemfile
|
34
|
-
- README.
|
34
|
+
- README.md
|
35
35
|
- Rakefile
|
36
36
|
- lib/load_speed.rb
|
37
37
|
- lib/stopwatch.rb
|
38
38
|
- lib/stopwatch/version.rb
|
39
39
|
- lib/stopwatch_log.rb
|
40
40
|
- stopwatch.gemspec
|
41
|
+
- stopwatch.png
|
41
42
|
has_rdoc: true
|
42
|
-
homepage:
|
43
|
+
homepage: https://github.com/bittersweet/stopwatch
|
43
44
|
licenses: []
|
44
45
|
|
45
46
|
post_install_message:
|
@@ -68,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
69
|
requirements: []
|
69
70
|
|
70
71
|
rubyforge_project: stopwatch
|
71
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.4.1
|
72
73
|
signing_key:
|
73
74
|
specification_version: 3
|
74
75
|
summary: Show the page load duration.
|
data/README.rdoc
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
= Stopwatch
|
2
|
-
|
3
|
-
This is a simple gem to load a Rack middleware that works together with the
|
4
|
-
Rails 3 Notification API to display the page load time and amount of queries
|
5
|
-
executed
|
6
|
-
|
7
|
-
== Installation
|
8
|
-
|
9
|
-
just add the following to the development group in your Gemfile.
|
10
|
-
|
11
|
-
gem 'stopwatch', :git => https://github.com/bittersweet/stopwatch
|
12
|
-
|
13
|
-
== Caveats
|
14
|
-
|
15
|
-
* It removes etags so we can display it fresh every page load, otherwise the response would get cached by the browser because Rails would return a 304 Not Modified.
|
16
|
-
|
17
|
-
== Todo
|
18
|
-
|
19
|
-
* Basic configuration
|
20
|
-
* Differentiate between cached and non-cached queries
|