Skip to content

Instantly share code, notes, and snippets.

@paul
Created December 3, 2008 05:51
Show Gist options
  • Save paul/31431 to your computer and use it in GitHub Desktop.
Save paul/31431 to your computer and use it in GitHub Desktop.
class ExceptionModel
def is_false
false
end
def kaboom!
raise "boom!"
end
end
class ExceptionBench < Merb::Controller
ERROR_MSG = "There was a problem"
def no_exception
em = ExceptionModel.new
ERROR_MSG unless em.is_false
end
def exception
em = ExceptionModel.new
begin
em.kaboom!
rescue StandardError => e
ERROR_MSG
end
end
end
class OrmExceptionModel
include DataMapper::Resource
property :id, Serial
property :name, String, :nullable => false
def save!
raise "Save Failed" unless save
end
end
class OrmExceptionBench < Merb::Controller
ERROR_MSG = "There was a problem"
def no_exception
em = OrmExceptionModel.new
ERROR_MSG unless em.save
end
def exception
em = ExceptionModel.new
begin
em.save!
rescue StandardError => e
ERROR_MSG
end
end
end
% ab -n10000 localhost:4000/exception
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Finished 10000 requests
Server Software:
Server Hostname: localhost
Server Port: 4000
Document Path: /exception
Document Length: 19 bytes
Concurrency Level: 1
Time taken for tests: 20.311 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1540000 bytes
HTML transferred: 190000 bytes
Requests per second: 492.33 [#/sec] (mean)
Time per request: 2.031 [ms] (mean)
Time per request: 2.031 [ms] (mean, across all concurrent requests)
Transfer rate: 74.04 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 1 2 3.3 2 57
Waiting: 1 2 3.3 2 57
Total: 1 2 3.3 2 57
Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 2
90% 2
95% 2
98% 2
99% 3
100% 57 (longest request)
% ab -n10000 localhost:4000/no_exception
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Finished 10000 requests
Server Software:
Server Hostname: localhost
Server Port: 4000
Document Path: /no_exception
Document Length: 19 bytes
Concurrency Level: 1
Time taken for tests: 19.541 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1540000 bytes
HTML transferred: 190000 bytes
Requests per second: 511.73 [#/sec] (mean)
Time per request: 1.954 [ms] (mean)
Time per request: 1.954 [ms] (mean, across all concurrent requests)
Transfer rate: 76.96 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 1 2 3.5 2 71
Waiting: 1 2 3.5 2 71
Total: 1 2 3.5 2 71
Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 2
90% 2
95% 2
98% 2
99% 3
100% 71 (longest request)
% ab -n10000 localhost:4000/orm/exception
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: thin
Server Hostname: localhost
Server Port: 4000
Document Path: /orm/exception
Document Length: 19 bytes
Concurrency Level: 1
Time taken for tests: 18.786 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1430000 bytes
HTML transferred: 190000 bytes
Requests per second: 532.31 [#/sec] (mean)
Time per request: 1.879 [ms] (mean)
Time per request: 1.879 [ms] (mean, across all concurrent requests)
Transfer rate: 74.34 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 4
Processing: 1 2 3.3 2 67
Waiting: 0 2 3.3 2 67
Total: 1 2 3.3 2 67
Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 2
90% 2
95% 2
98% 2
99% 2
100% 67 (longest request)
% ab -n10000 localhost:4000/orm/no_exception
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: thin
Server Hostname: localhost
Server Port: 4000
Document Path: /orm/no_exception
Document Length: 19 bytes
Concurrency Level: 1
Time taken for tests: 24.778 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1430000 bytes
HTML transferred: 190000 bytes
Requests per second: 403.59 [#/sec] (mean)
Time per request: 2.478 [ms] (mean)
Time per request: 2.478 [ms] (mean, across all concurrent requests)
Transfer rate: 56.36 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 4
Processing: 2 2 3.5 2 98
Waiting: 2 2 3.5 2 98
Total: 2 2 3.5 2 98
Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 2
90% 2
95% 2
98% 2
99% 4
100% 98 (longest request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment