new
Benchmark.bmbm do |b|
b.report("Ruby factorial") do
200_000.times { t.factorial(20) }
end
b.report("C factorial") do
200_000.times { t.factorial_c(20) }
end
end
On my machine, the C implementation is extremely fast??”more than 25 times the
speed of the standard Ruby implementation!
user system total real
Ruby factorial 2.760000 0.010000 2.770000 ( 2.753621)
C factorial 0.110000 0.000000 0.110000 ( 0.104440)
The best part of RubyInline is that it keeps your code clean. Ruby and C code
addressing the same area can be intermingled, rather than being spread across multiple
files. And RubyInline handles the type conversion for you??”you can deal with
ints, longs, and char *s, and they will automatically be converted to and from Ruby
types.
ActionMailer
Email delivery can be a difficult and aggravating aspect of a deployed application.
The SMTPprotocol was not designed to withstand the types of attacks that are being
directed at the mail system today, and so delivering mail can be a more complicated
process than it may seem.
184 | Chapter 6: Performance
One common problem is that email delivery via SMTPis quite slow, on the average.
In addition, it is an unknown; the time it takes to send one email is highly variable.
Even when delivering to an SMTPrelay on the local network (which is a good idea
for high-volume sites), SMTP delivery is slow.
To counteract this slowness, it is usually desirable to decouple the email sending
from the web request/response cycle.
Pages:
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286