Module: Dlog::Benchslow
Instance Method Summary
collapse
Methods included from Benchmark
#debug, #error, #info, #warn
Instance Method Details
#benchmark(severity, args, &block) ⇒ Object
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
# File 'lib/dlog.rb', line 240
def benchmark(severity, args, &block)
args.push "#{args.pop}:" if args.last.is_a?(String)
start = Time.now
r = yield
timespan = Time.now - start
if timespan > 1
args.push "%d msecs" % (1000 * timespan)
Dlog.log severity, args, 2
end
r
rescue
args.push "exception raised after #{"%d msecs" % (1000 * (Time.now - start)) }"
Dlog.log severity, args, 2
raise
end
|