rawk_log 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +3 -0
- data/README.md +74 -0
- data/Rakefile +14 -0
- data/bin/rawk_log +298 -0
- data/lib/rawk_log/patch_activesupport_bufferedlogger.rb +22 -0
- data/lib/rawk_log/patch_logger.rb +9 -0
- data/lib/rawk_log/version.rb +3 -0
- data/lib/rawk_log.rb +7 -0
- data/rawk_log.gemspec +23 -0
- data/test/examples/mixed_rails40.log +115 -0
- data/test/examples/rails23.log +27 -0
- data/test/examples/rails40.log +88 -0
- data/test/mixed_rails40_test.rb +34 -0
- data/test/rails23_test.rb +31 -0
- data/test/rails40_test.rb +31 -0
- data/test/self_test.rb +22 -0
- metadata +112 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# RawkLog
|
2
|
+
|
3
|
+
RawkLog - RAWK - Rail's Analyzer With Klass updated and packaged a Gem
|
4
|
+
|
5
|
+
This tool gives statistics for Ruby on Rails log files. The times for each request are grouped and totals are displayed. If process ids are present in the log files then requests are sorted by ActionController actions otherwise requests are grouped by url. By default total request times are used for comparison but database time or render time can be used by specifying the correct flag. The log file is read from standard input unless the -f flag is specified.
|
6
|
+
|
7
|
+
[![Travis CI tests](https://travis-ci.org/ianheggie/rawk_log.png)](https://travis-ci.org/ianheggie/rawk_log)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'rawk_log'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rawk_log
|
22
|
+
|
23
|
+
This will
|
24
|
+
|
25
|
+
1. add the rawk_log command
|
26
|
+
2. adjust Logger and ActiveSupport::BufferedLogger to append " (pid:#{$$})" to log lines so urls can be related to their controller and method (if added to the Gemfile)
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
rawk_log usage:
|
31
|
+
|
32
|
+
-? Display this help.
|
33
|
+
|
34
|
+
-d Use DB times as data points. These times are found after 'DB:' in the log file. This overrides the default behavior of using the total request time.
|
35
|
+
|
36
|
+
-f <filename> Use the specified file instead of standard input.
|
37
|
+
|
38
|
+
-h Display this help.
|
39
|
+
|
40
|
+
-r Use Render times as data points. These times are found after 'Rendering:' in the log file. This overrides the default behavior of using the total request time.
|
41
|
+
|
42
|
+
-s <count> Display <count> results in each group of data.
|
43
|
+
|
44
|
+
-t Test
|
45
|
+
|
46
|
+
-u Group requests by url instead of the controller and action used. This is the default behavior if there is are no process ids in the log file.
|
47
|
+
|
48
|
+
-w <count> Display the top <count> worst requests.
|
49
|
+
|
50
|
+
-x <date> Date (inclusive) to start parsing in 'yyyy-mm-dd' format.
|
51
|
+
|
52
|
+
-y <date> Date (inclusive) to stop parsing in 'yyyy-mm-dd' format.
|
53
|
+
|
54
|
+
Example usage:
|
55
|
+
rawk_log log/production.log
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
1. Fork it
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create new Pull Request
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
This software is Beerware, if you like it, buy yourself a beer
|
68
|
+
or something nicer ;)
|
69
|
+
|
70
|
+
## Thanks go to
|
71
|
+
|
72
|
+
* Created by Chris Hobbs of Spongecell, LLC - http://ckhsponge.wordpress.com/2006/10/11/ruby-on-rails-log-analyzer-rawk/
|
73
|
+
* Various contributers on github
|
74
|
+
* Railscast for bringing it to my attention: http://railscasts.com/episodes/97-analyzing-the-production-log
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
desc 'Test the rawk_log gem'
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'lib'
|
8
|
+
t.pattern = 'test/**/*_test.rb'
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Run tests"
|
13
|
+
task :default => :test
|
14
|
+
|
data/bin/rawk_log
ADDED
@@ -0,0 +1,298 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
##Rail's Analyzer With Klass
|
3
|
+
#run the following to view help:
|
4
|
+
#ruby rawk.rb -?
|
5
|
+
require 'date'
|
6
|
+
class Stat
|
7
|
+
def initialize(key)
|
8
|
+
@key=key
|
9
|
+
@min = nil
|
10
|
+
@max = nil
|
11
|
+
@sum = 0
|
12
|
+
@sum_squares = 0
|
13
|
+
@count = 0
|
14
|
+
@values = []
|
15
|
+
end
|
16
|
+
def add(value)
|
17
|
+
@new_log_format = !value.is_a?(Float)
|
18
|
+
value=1.0*value
|
19
|
+
@count+=1
|
20
|
+
@min = value unless @min
|
21
|
+
@min = value if value<@min
|
22
|
+
@max = value unless @max
|
23
|
+
@max = value if value>@max
|
24
|
+
@sum += value
|
25
|
+
@sum_squares += value*value
|
26
|
+
@values << value
|
27
|
+
end
|
28
|
+
def key
|
29
|
+
@key
|
30
|
+
end
|
31
|
+
def count
|
32
|
+
@count
|
33
|
+
end
|
34
|
+
def sum
|
35
|
+
@sum
|
36
|
+
end
|
37
|
+
def min
|
38
|
+
@min
|
39
|
+
end
|
40
|
+
def max
|
41
|
+
@max
|
42
|
+
end
|
43
|
+
def average
|
44
|
+
@sum/@count
|
45
|
+
end
|
46
|
+
def median
|
47
|
+
return nil unless @values
|
48
|
+
l = @values.length
|
49
|
+
return nil unless l>0
|
50
|
+
@values.sort!
|
51
|
+
return (@values[l/2-1]+@values[l/2])/2 if l%2==0
|
52
|
+
@values[(l+1)/2-1]
|
53
|
+
end
|
54
|
+
def standard_deviation
|
55
|
+
return 0 if @count<=1
|
56
|
+
Math.sqrt((@sum_squares - (@sum*@sum/@count))/ (@count) )
|
57
|
+
end
|
58
|
+
def to_s
|
59
|
+
if @new_log_format
|
60
|
+
sprintf("%-55s %6d %7.2f %7d %7d %7d %7d %7d",key,count,(sum.to_f/1000),max,median,average,min,standard_deviation)
|
61
|
+
else
|
62
|
+
sprintf("%-55s %6d %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f",key,count,sum,max,median,average,min,standard_deviation)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.test
|
67
|
+
stat = Stat.new(30)
|
68
|
+
stat.add(5)
|
69
|
+
stat.add(6)
|
70
|
+
stat.add(8)
|
71
|
+
stat.add(9)
|
72
|
+
messages = [ 7==stat.median ? "median Success" : "median Failure" ]
|
73
|
+
messages <<= (7==stat.average ? "average Success" : "average Failure")
|
74
|
+
messages <<= (158==(stat.standard_deviation*100).round ? "std Success" : "std Failure")
|
75
|
+
puts messages.join("\n")
|
76
|
+
exit (messages.select{|m| m =~ /Failure/}.size)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
class StatHash
|
81
|
+
def initialize
|
82
|
+
@stats = Hash.new
|
83
|
+
end
|
84
|
+
def add(key,time)
|
85
|
+
stat = @stats[key] || (@stats[key] = Stat.new(key))
|
86
|
+
stat.add(time)
|
87
|
+
end
|
88
|
+
def print(args={:sort_by=>'key',:ascending=>true,:limit=>nil})
|
89
|
+
values = @stats.values
|
90
|
+
order = (args[:ascending] || args[:ascending].nil?) ? 1 : -1
|
91
|
+
values.sort! {|a,b|
|
92
|
+
as = a.send(args[:sort_by])
|
93
|
+
bs = b.send(args[:sort_by])
|
94
|
+
(as && bs) ? order*(as<=>bs) : 0
|
95
|
+
}
|
96
|
+
#values.sort! {|a,b| a.key<=>b.key}
|
97
|
+
limit = args[:limit]
|
98
|
+
for stat in values
|
99
|
+
break if limit && limit<=0
|
100
|
+
puts stat.to_s
|
101
|
+
limit-=1 if limit
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class Rawk
|
107
|
+
VERSION = 2.0
|
108
|
+
HEADER = "Request Count Sum Max Median Avg Min Std"
|
109
|
+
HEADER_NEW_LOG_FORMAT = "Request Count Sum(s) Max Median Avg Min Std"
|
110
|
+
HELP = "\nRAWK - Rail's Analyzer With Klass v#{VERSION}\n"+
|
111
|
+
"Created by Chris Hobbs of Spongecell, LLC\n"+
|
112
|
+
"This tool gives statistics for Ruby on Rails log files. The times for each request are grouped and totals are displayed. "+
|
113
|
+
"If process ids are present in the log files then requests are sorted by ActionController actions otherwise requests are grouped by url. "+
|
114
|
+
"By default total request times are used for comparison but database time or render time can be used by specifying the correct flag. "+
|
115
|
+
"The log file is read from standard input unless the -f flag is specified.\n\n"+
|
116
|
+
"The options are as follows:\n\n"+
|
117
|
+
" -? Display this help.\n\n"+
|
118
|
+
" -d Use DB times as data points. These times are found after 'DB:' in the log file. This overrides the default behavior of using the total request time.\n\n"+
|
119
|
+
" -f <filename> Use the specified file instead of standard input.\n\n"+
|
120
|
+
" -h Display this help.\n\n"+
|
121
|
+
" -r Use Render times as data points. These times are found after 'Rendering:' in the log file. This overrides the default behavior of using the total request time.\n\n"+
|
122
|
+
" -s <count> Display <count> results in each group of data.\n\n"+
|
123
|
+
" -t Test\n\n"+
|
124
|
+
" -u Group requests by url instead of the controller and action used. This is the default behavior if there is are no process ids in the log file.\n\n"+
|
125
|
+
" -w <count> Display the top <count> worst requests.\n\n"+
|
126
|
+
" -x <date> Date (inclusive) to start parsing in 'yyyy-mm-dd' format.\n\n"+
|
127
|
+
" -y <date> Date (inclusive) to stop parsing in 'yyyy-mm-dd' format.\n\n"+
|
128
|
+
"To include process ids in your log file, add this to application's Gemfile:\n\n"+
|
129
|
+
" gem 'rawk_log'\n\n"+
|
130
|
+
"This software is Beerware, if you like it, buy yourself a beer or something nicer ;)\n"+
|
131
|
+
"\n"+
|
132
|
+
"Example usage:\n"+
|
133
|
+
" rawk_log log/production.log\n"
|
134
|
+
|
135
|
+
def initialize
|
136
|
+
@start_time = Time.now
|
137
|
+
build_arg_hash
|
138
|
+
if @arg_hash.keys.include?("?") || @arg_hash.keys.include?("h")
|
139
|
+
puts HELP
|
140
|
+
elsif @arg_hash.keys.include?("t")
|
141
|
+
Stat.test
|
142
|
+
else
|
143
|
+
init_args
|
144
|
+
build_stats
|
145
|
+
print_stats
|
146
|
+
end
|
147
|
+
end
|
148
|
+
def build_arg_hash
|
149
|
+
@arg_hash = Hash.new
|
150
|
+
last_key=nil
|
151
|
+
for a in $*
|
152
|
+
if a.index("-")==0 && a.length>1
|
153
|
+
a[1,1000].scan(/[a-z]|\?/).each {|c| @arg_hash[last_key=c]=nil}
|
154
|
+
@arg_hash[last_key] = a[/\d+/] if last_key
|
155
|
+
elsif a.index("-")!=0 && last_key
|
156
|
+
@arg_hash[last_key] = a
|
157
|
+
end
|
158
|
+
end
|
159
|
+
#$* = [$*[0]]
|
160
|
+
end
|
161
|
+
def init_args
|
162
|
+
@sorted_limit=20
|
163
|
+
@worst_request_length=20
|
164
|
+
@force_url_use = false
|
165
|
+
@db_time = false
|
166
|
+
@render_time = false
|
167
|
+
@input = $stdin
|
168
|
+
keys = @arg_hash.keys
|
169
|
+
@force_url_use = keys.include?("u")
|
170
|
+
@db_time = keys.include?("d")
|
171
|
+
@render_time = keys.include?("r")
|
172
|
+
@worst_request_length=(@arg_hash["w"].to_i) if @arg_hash["w"]
|
173
|
+
@sorted_limit = @arg_hash["s"].to_i if @arg_hash["s"]
|
174
|
+
@input = File.new(@arg_hash["f"]) if @arg_hash["f"]
|
175
|
+
@from =(Date.parse(@arg_hash["x"])) if @arg_hash["x"]
|
176
|
+
@to =(Date.parse(@arg_hash["y"])) if @arg_hash["y"]
|
177
|
+
end
|
178
|
+
|
179
|
+
def is_id?(word)
|
180
|
+
word =~ /^((\d+)|([\dA-F\-]{36}))$/i
|
181
|
+
end
|
182
|
+
|
183
|
+
def build_stats
|
184
|
+
@stat_hash = StatHash.new
|
185
|
+
@total_stat = Stat.new("All Requests")
|
186
|
+
@worst_requests = []
|
187
|
+
last_actions = Hash.new
|
188
|
+
while @input.gets
|
189
|
+
if $_.index("Processing ")==0
|
190
|
+
action = $_.split[1]
|
191
|
+
pid = $_[/\(pid\:\d+\)/]
|
192
|
+
date = Date.parse($_[/(?:19|20)[0-9]{2}-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|3[01])/])
|
193
|
+
datetime = $_[/(?:19|20)[0-9]{2}-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|3[01]) (?:[0-1][0-9]|2[0-3]):(?:[0-5][0-9]|60):(?:[0-5][0-9]|60)/]
|
194
|
+
last_actions[pid]=action if pid
|
195
|
+
next
|
196
|
+
end
|
197
|
+
next unless $_.index("Completed in")==0
|
198
|
+
pid = key = nil
|
199
|
+
#get the pid unless we are forcing url tracking
|
200
|
+
pid = $_[/\(pid\:\d+\)/] if !@force_url_use
|
201
|
+
key = last_actions[pid] if pid
|
202
|
+
time = 0.0
|
203
|
+
|
204
|
+
# Old: Completed in 0.45141 (2 reqs/sec) | Rendering: 0.25965 (57%) | DB: 0.06300 (13%) | 200 OK [http://localhost/jury/proposal/312]
|
205
|
+
# New: Completed in 100ms (View: 40, DB: 4)
|
206
|
+
unless defined? @new_log_format
|
207
|
+
@new_log_format = $_ =~ /Completed in \d+ms/
|
208
|
+
end
|
209
|
+
|
210
|
+
if @new_log_format
|
211
|
+
if @db_time
|
212
|
+
time_string = $_[/DB: \d+/]
|
213
|
+
elsif @render_time
|
214
|
+
time_string = $_[/View: \d+/]
|
215
|
+
else
|
216
|
+
time_string = $_[/Completed in \d+ms/]
|
217
|
+
end
|
218
|
+
time_string = time_string[/\d+/] if time_string
|
219
|
+
time = time_string.to_i if time_string
|
220
|
+
else
|
221
|
+
if @db_time
|
222
|
+
time_string = $_[/DB: \d+\.\d+/]
|
223
|
+
elsif @render_time
|
224
|
+
time_string = $_[/Rendering: \d+\.\d+/]
|
225
|
+
else
|
226
|
+
time_string = $_[/Completed in \d+\.\d+/]
|
227
|
+
end
|
228
|
+
time_string = time_string[/\d+\.\d+/] if time_string
|
229
|
+
time = time_string.to_f if time_string
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
#if pids are not specified then we use the url for hashing
|
234
|
+
#the below regexp turns "[http://spongecell.com/calendar/view/bob]" to "/calendar/view"
|
235
|
+
unless key
|
236
|
+
|
237
|
+
key = if @force_url_use
|
238
|
+
($_[/\[\S+\]/].gsub(/\S+\/\/(\w|\.)*/,''))[/[^\?\]]*/]
|
239
|
+
else
|
240
|
+
data = $_[/\[\S+\]/].gsub(/\S+\/\/(\w|\.)*/,'')
|
241
|
+
s = data.gsub(/(\?.*)|\]$/,'').split("/")
|
242
|
+
|
243
|
+
keywords = s.inject([]) do |keywords, word|
|
244
|
+
if is_id?(word.to_s)
|
245
|
+
keywords << '{ID}'
|
246
|
+
elsif !word.to_s.empty?
|
247
|
+
keywords << word.to_s
|
248
|
+
end
|
249
|
+
keywords
|
250
|
+
end
|
251
|
+
k = "/#{keywords.join("/")}"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
if (@from.nil? or @from <= date) and (@to.nil? or @to >= date) # date criteria here
|
256
|
+
@stat_hash.add(key,time)
|
257
|
+
@total_stat.add(time)
|
258
|
+
if @worst_requests.length<@worst_request_length || @worst_requests[@worst_request_length-1][0]<time
|
259
|
+
@worst_requests << [time,%Q(#{datetime} #{$_})]
|
260
|
+
@worst_requests.sort! {|a,b| (b[0] && a[0]) ? b[0]<=>a[0] : 0}
|
261
|
+
@worst_requests=@worst_requests[0,@worst_request_length]
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
def print_stats
|
267
|
+
@header ||= @new_log_format ? HEADER_NEW_LOG_FORMAT : HEADER
|
268
|
+
puts "Printing report for #{@db_time ? 'DB' : @render_time ? 'render' : 'total'} request times#{@from ? %Q( from #{@from.to_s}) : ""}#{@to ? %Q( through #{@to.to_s}) : ""}"
|
269
|
+
puts "--------"
|
270
|
+
puts @header
|
271
|
+
puts @total_stat.to_s
|
272
|
+
puts "--------"
|
273
|
+
@stat_hash.print()
|
274
|
+
puts "\nTop #{@sorted_limit} by Count"
|
275
|
+
puts @header
|
276
|
+
@stat_hash.print(:sort_by=>"count",:limit=>@sorted_limit,:ascending=>false)
|
277
|
+
puts "\nTop #{@sorted_limit} by Sum of Time"
|
278
|
+
puts @header
|
279
|
+
@stat_hash.print(:sort_by=>"sum",:limit=>@sorted_limit,:ascending=>false)
|
280
|
+
puts "\nTop #{@sorted_limit} Greatest Max"
|
281
|
+
puts @header
|
282
|
+
@stat_hash.print(:sort_by=>"max",:limit=>@sorted_limit,:ascending=>false)
|
283
|
+
puts "\nTop #{@sorted_limit} Least Min"
|
284
|
+
puts @header
|
285
|
+
@stat_hash.print(:sort_by=>"min",:limit=>@sorted_limit)
|
286
|
+
puts "\nTop #{@sorted_limit} Greatest Median"
|
287
|
+
puts @header
|
288
|
+
@stat_hash.print(:sort_by=>"median",:limit=>@sorted_limit,:ascending=>false)
|
289
|
+
puts "\nTop #{@sorted_limit} Greatest Standard Deviation"
|
290
|
+
puts @header
|
291
|
+
@stat_hash.print(:sort_by=>"standard_deviation",:limit=>@sorted_limit,:ascending=>false)
|
292
|
+
puts "\nWorst Requests"
|
293
|
+
@worst_requests.each {|w| puts w[1].to_s}
|
294
|
+
puts "\nCompleted report in #{(Time.now.to_i-@start_time.to_i)/60.0} minutes -- spongecell"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
Rawk.new
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
if defined?(ActiveSupport::BufferedLogger)
|
3
|
+
|
4
|
+
module ActiveSupport
|
5
|
+
|
6
|
+
# Format the buffered logger with timestamp/severity info.
|
7
|
+
class BufferedLogger
|
8
|
+
def add(severity, message = nil, progname = nil, &block)
|
9
|
+
return if @level > severity
|
10
|
+
message = (message || (block && block.call) || progname).to_s
|
11
|
+
# If a newline is necessary then create a new message ending with a newline.
|
12
|
+
# Ensures that the original message is not mutated.
|
13
|
+
message = "#{message}\n" unless message[-1] == ?\n
|
14
|
+
message = message.gsub(/\n/," (pid:#{$$})\n")
|
15
|
+
buffer << message
|
16
|
+
auto_flush
|
17
|
+
message
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/lib/rawk_log.rb
ADDED
data/rawk_log.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rawk_log/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rawk_log"
|
8
|
+
spec.version = RawkLog::VERSION
|
9
|
+
spec.authors = ["Chris Hobbs", "Ian Heggie"]
|
10
|
+
spec.email = ["chris.hobbs@unknown.due.to.spam", "ian@heggie.biz"]
|
11
|
+
spec.description = %q{RawkLog - RAWK - Rail's Analyzer With Klass updated and packaged a Gem}
|
12
|
+
spec.summary = %q{This tool gives statistics for Ruby on Rails log files. The times for each request are grouped and totals are displayed. If process ids are present in the log files then requests are sorted by ActionController actions otherwise requests are grouped by url. By default total request times are used for comparison but database time or render time can be used by specifying the correct flag. The log file is read from standard input unless the -f flag is specified.}
|
13
|
+
spec.homepage = "https://github.com/ianheggie/rawk_log"
|
14
|
+
spec.license = "Beerware"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# From http://guides.rubyonrails.org/v2.3.11/performance_testing.html
|
2
|
+
|
3
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET] (pid:1234)
|
4
|
+
Rendering template within layouts/items (pid:1234)
|
5
|
+
|
6
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST] (pid:9876)
|
7
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl (pid:9876)
|
8
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4 (pid:9876)
|
9
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails", (pid:9876)
|
10
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"}, (pid:9876)
|
11
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"} (pid:9876)
|
12
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!", (pid:9876)
|
13
|
+
"published"=>false, "created_at"=>nil} (pid:9876)
|
14
|
+
Post should be valid: true (pid:9876)
|
15
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published", (pid:9876)
|
16
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails', (pid:9876)
|
17
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54') (pid:9876)
|
18
|
+
The post was saved and now the user is going to be redirected... (pid:9876)
|
19
|
+
Redirected to #<Post:0x20af760> (pid:9876)
|
20
|
+
Completed in 0.03224 (81 reqs/sec) | DB: 0.01044 (3%) | 302 Found [http://localhost/posts] (pid:9876)
|
21
|
+
|
22
|
+
Rendering items/index (pid:1234)
|
23
|
+
Completed in 0.02500 (View: 22, DB: 20) | 200 OK [http://0.0.0.0/items] (pid:1234)
|
24
|
+
|
25
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET] (pid:1000)
|
26
|
+
Rendering template within layouts/items (pid:1000)
|
27
|
+
Rendering items/index (pid:1000)
|
28
|
+
|
29
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET] (pid:1234)
|
30
|
+
Rendering template within layouts/items (pid:1234)
|
31
|
+
Rendering items/index (pid:1234)
|
32
|
+
Completed in 0.00500 (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items] (pid:1234)
|
33
|
+
|
34
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET] (pid:1234)
|
35
|
+
Rendering template within layouts/items (pid:1234)
|
36
|
+
Rendering items/index (pid:1234)
|
37
|
+
Completed in 0.00500 (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items] (pid:1234)
|
38
|
+
|
39
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET] (pid:1234)
|
40
|
+
Rendering template within layouts/items (pid:1234)
|
41
|
+
|
42
|
+
#From http://guides.rubyonrails.org/v4.0.0/debugging_rails_applications.html
|
43
|
+
|
44
|
+
|
45
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST] (pid:9876)
|
46
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl (pid:9876)
|
47
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4 (pid:9876)
|
48
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails", (pid:9876)
|
49
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"}, (pid:9876)
|
50
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"} (pid:9876)
|
51
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!", (pid:9876)
|
52
|
+
"published"=>false, "created_at"=>nil} (pid:9876)
|
53
|
+
Post should be valid: true (pid:9876)
|
54
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published", (pid:9876)
|
55
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails', (pid:9876)
|
56
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54') (pid:9876)
|
57
|
+
The post was saved and now the user is going to be redirected... (pid:9876)
|
58
|
+
Redirected to #<Post:0x20af760> (pid:9876)
|
59
|
+
Completed in 0.02224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts] (pid:9876)
|
60
|
+
|
61
|
+
|
62
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST] (pid:9876)
|
63
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl (pid:9876)
|
64
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4 (pid:9876)
|
65
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails", (pid:9876)
|
66
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"}, (pid:9876)
|
67
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"} (pid:9876)
|
68
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!", (pid:9876)
|
69
|
+
"published"=>false, "created_at"=>nil} (pid:9876)
|
70
|
+
Post should be valid: true (pid:9876)
|
71
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published", (pid:9876)
|
72
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails', (pid:9876)
|
73
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54') (pid:9876)
|
74
|
+
The post was saved and now the user is going to be redirected... (pid:9876)
|
75
|
+
Redirected to #<Post:0x20af760> (pid:9876)
|
76
|
+
Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts] (pid:9876)
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST] (pid:9876)
|
81
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl (pid:9876)
|
82
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4 (pid:9876)
|
83
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails", (pid:9876)
|
84
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"}, (pid:9876)
|
85
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"} (pid:9876)
|
86
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!", (pid:9876)
|
87
|
+
"published"=>false, "created_at"=>nil} (pid:9876)
|
88
|
+
Post should be valid: true (pid:9876)
|
89
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published", (pid:9876)
|
90
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails', (pid:9876)
|
91
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54') (pid:9876)
|
92
|
+
The post was saved and now the user is going to be redirected... (pid:9876)
|
93
|
+
Redirected to #<Post:0x20af760> (pid:9876)
|
94
|
+
Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts] (pid:9876)
|
95
|
+
|
96
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST] (pid:9876)
|
97
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl (pid:9876)
|
98
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4 (pid:9876)
|
99
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails", (pid:9876)
|
100
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"}, (pid:9876)
|
101
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"} (pid:9876)
|
102
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!", (pid:9876)
|
103
|
+
"published"=>false, "created_at"=>nil} (pid:9876)
|
104
|
+
Post should be valid: true (pid:9876)
|
105
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published", (pid:9876)
|
106
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails', (pid:9876)
|
107
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54') (pid:9876)
|
108
|
+
The post was saved and now the user is going to be redirected... (pid:9876)
|
109
|
+
Redirected to #<Post:0x20af760> (pid:9876)
|
110
|
+
Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts] (pid:9876)
|
111
|
+
|
112
|
+
Rendering items/index (pid:1234)
|
113
|
+
Completed in 0.00500 (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items] (pid:1234)
|
114
|
+
|
115
|
+
Completed in 0.01500 (View: 12, DB: 10) | 200 OK [http://0.0.0.0/items] (pid:1000)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# From http://guides.rubyonrails.org/v2.3.11/performance_testing.html
|
2
|
+
|
3
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET]
|
4
|
+
Rendering template within layouts/items
|
5
|
+
Rendering items/index
|
6
|
+
Completed in 25ms (View: 22, DB: 20) | 200 OK [http://0.0.0.0/items]
|
7
|
+
|
8
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET]
|
9
|
+
Rendering template within layouts/items
|
10
|
+
Rendering items/index
|
11
|
+
Completed in 15ms (View: 12, DB: 10) | 200 OK [http://0.0.0.0/items]
|
12
|
+
|
13
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET]
|
14
|
+
Rendering template within layouts/items
|
15
|
+
Rendering items/index
|
16
|
+
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items]
|
17
|
+
|
18
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET]
|
19
|
+
Rendering template within layouts/items
|
20
|
+
Rendering items/index
|
21
|
+
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items]
|
22
|
+
|
23
|
+
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET]
|
24
|
+
Rendering template within layouts/items
|
25
|
+
Rendering items/index
|
26
|
+
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items]
|
27
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#From http://guides.rubyonrails.org/v4.0.0/debugging_rails_applications.html
|
2
|
+
|
3
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST]
|
4
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl
|
5
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4
|
6
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails",
|
7
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"},
|
8
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"}
|
9
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!",
|
10
|
+
"published"=>false, "created_at"=>nil}
|
11
|
+
Post should be valid: true
|
12
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published",
|
13
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails',
|
14
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54')
|
15
|
+
The post was saved and now the user is going to be redirected...
|
16
|
+
Redirected to #<Post:0x20af760>
|
17
|
+
Completed in 0.03224 (81 reqs/sec) | DB: 0.01044 (3%) | 302 Found [http://localhost/posts]
|
18
|
+
|
19
|
+
|
20
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST]
|
21
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl
|
22
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4
|
23
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails",
|
24
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"},
|
25
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"}
|
26
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!",
|
27
|
+
"published"=>false, "created_at"=>nil}
|
28
|
+
Post should be valid: true
|
29
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published",
|
30
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails',
|
31
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54')
|
32
|
+
The post was saved and now the user is going to be redirected...
|
33
|
+
Redirected to #<Post:0x20af760>
|
34
|
+
Completed in 0.02224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts]
|
35
|
+
|
36
|
+
|
37
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST]
|
38
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl
|
39
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4
|
40
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails",
|
41
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"},
|
42
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"}
|
43
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!",
|
44
|
+
"published"=>false, "created_at"=>nil}
|
45
|
+
Post should be valid: true
|
46
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published",
|
47
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails',
|
48
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54')
|
49
|
+
The post was saved and now the user is going to be redirected...
|
50
|
+
Redirected to #<Post:0x20af760>
|
51
|
+
Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts]
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST]
|
56
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl
|
57
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4
|
58
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails",
|
59
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"},
|
60
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"}
|
61
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!",
|
62
|
+
"published"=>false, "created_at"=>nil}
|
63
|
+
Post should be valid: true
|
64
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published",
|
65
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails',
|
66
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54')
|
67
|
+
The post was saved and now the user is going to be redirected...
|
68
|
+
Redirected to #<Post:0x20af760>
|
69
|
+
Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts]
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
Processing PostsController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST]
|
74
|
+
Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl
|
75
|
+
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4
|
76
|
+
Parameters: {"commit"=>"Create", "post"=>{"title"=>"Debugging Rails",
|
77
|
+
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"},
|
78
|
+
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"posts"}
|
79
|
+
New post: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!",
|
80
|
+
"published"=>false, "created_at"=>nil}
|
81
|
+
Post should be valid: true
|
82
|
+
Post Create (0.000443) INSERT INTO "posts" ("updated_at", "title", "body", "published",
|
83
|
+
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails',
|
84
|
+
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54')
|
85
|
+
The post was saved and now the user is going to be redirected...
|
86
|
+
Redirected to #<Post:0x20af760>
|
87
|
+
Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts]
|
88
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class MixedRails40Test < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@output = `ruby bin/rawk_log -f test/examples/mixed_rails40.log`
|
7
|
+
@exit_status = $?.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_methods_reported
|
11
|
+
assert_match(/ItemsController/, @output)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_outputs_header
|
15
|
+
assert_match(/^Request +Count +Sum +Max +Median +Avg +Min +Std$/, @output)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_finds_entries
|
19
|
+
assert_match(/^ItemsController#index/, @output)
|
20
|
+
assert_match(/^ItemsController#index\s+5\s/, @output)
|
21
|
+
assert_match(/^PostsController#create/, @output)
|
22
|
+
assert_match(/^PostsController#create\s+5\s/, @output)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_sums_entries
|
26
|
+
assert_match(/^Items\S+\s+5\s+0\.06/, @output)
|
27
|
+
assert_match(/^Posts\S+\s+5\s+0\.09/, @output)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_exit_status
|
31
|
+
assert_equal(0, @exit_status)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class Rails23Test < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@output = `ruby bin/rawk_log -f test/examples/rails23.log`
|
7
|
+
@exit_status = $?.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_no_methods_reported
|
11
|
+
assert_no_match(/ItemsController/, @output)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_outputs_header
|
15
|
+
assert_match(/^Request +Count +Sum\(s\) +Max +Median +Avg +Min +Std$/, @output)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_finds_entries
|
19
|
+
assert_match(/^\/items/, @output)
|
20
|
+
assert_match(/^\/items\s+5\s/, @output)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_sums_entries
|
24
|
+
assert_match(/^\/items\s+5\s+0\.06/, @output)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_exit_status
|
28
|
+
assert_equal(0, @exit_status)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class Rails40Test < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@output = `ruby bin/rawk_log -f test/examples/rails40.log`
|
7
|
+
@exit_status = $?.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_no_methods_reported
|
11
|
+
assert_no_match(/PostsController/, @output)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_outputs_header
|
15
|
+
assert_match(/^Request +Count +Sum +Max +Median +Avg +Min +Std$/, @output)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_finds_entries
|
19
|
+
assert_match(/^\/posts/, @output)
|
20
|
+
assert_match(/^\/posts\s+5\s/, @output)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_sums_entries
|
24
|
+
assert_match(/^\/posts+\s+5\s+0\.09/, @output)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_exit_status
|
28
|
+
assert_equal(0, @exit_status)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/test/self_test.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class SelfTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@output = `ruby bin/rawk_log -t`
|
7
|
+
@exit_status = $?.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_no_failures_reported
|
11
|
+
assert_no_match(/Failure/, @output)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_success_reported
|
15
|
+
assert_match(/Success/, @output)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_exit_status
|
19
|
+
assert_equal(0, @exit_status)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rawk_log
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Hobbs
|
9
|
+
- Ian Heggie
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-12-22 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.3'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.3'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rake
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: RawkLog - RAWK - Rail's Analyzer With Klass updated and packaged a Gem
|
48
|
+
email:
|
49
|
+
- chris.hobbs@unknown.due.to.spam
|
50
|
+
- ian@heggie.biz
|
51
|
+
executables:
|
52
|
+
- rawk_log
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- .travis.yml
|
58
|
+
- Gemfile
|
59
|
+
- LICENSE.txt
|
60
|
+
- README.md
|
61
|
+
- Rakefile
|
62
|
+
- bin/rawk_log
|
63
|
+
- lib/rawk_log.rb
|
64
|
+
- lib/rawk_log/patch_activesupport_bufferedlogger.rb
|
65
|
+
- lib/rawk_log/patch_logger.rb
|
66
|
+
- lib/rawk_log/version.rb
|
67
|
+
- rawk_log.gemspec
|
68
|
+
- test/examples/mixed_rails40.log
|
69
|
+
- test/examples/rails23.log
|
70
|
+
- test/examples/rails40.log
|
71
|
+
- test/mixed_rails40_test.rb
|
72
|
+
- test/rails23_test.rb
|
73
|
+
- test/rails40_test.rb
|
74
|
+
- test/self_test.rb
|
75
|
+
homepage: https://github.com/ianheggie/rawk_log
|
76
|
+
licenses:
|
77
|
+
- Beerware
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.8.23
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: This tool gives statistics for Ruby on Rails log files. The times for each
|
100
|
+
request are grouped and totals are displayed. If process ids are present in the
|
101
|
+
log files then requests are sorted by ActionController actions otherwise requests
|
102
|
+
are grouped by url. By default total request times are used for comparison but database
|
103
|
+
time or render time can be used by specifying the correct flag. The log file is
|
104
|
+
read from standard input unless the -f flag is specified.
|
105
|
+
test_files:
|
106
|
+
- test/examples/mixed_rails40.log
|
107
|
+
- test/examples/rails23.log
|
108
|
+
- test/examples/rails40.log
|
109
|
+
- test/mixed_rails40_test.rb
|
110
|
+
- test/rails23_test.rb
|
111
|
+
- test/rails40_test.rb
|
112
|
+
- test/self_test.rb
|