Module: Dlog::Benchmark

Extended by:
Benchmark
Included in:
Benchmark, Benchslow
Defined in:
lib/dlog.rb

Instance Method Summary collapse

Instance Method Details

#benchmark(severity, args, &block) ⇒ Object



206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/dlog.rb', line 206

def benchmark(severity, args, &block)
  args.push "#{args.pop}:" if args.last.is_a?(String)

  start = Time.now
  r = yield

  args.push "%d msecs" % (1000 * (Time.now - start))
  Dlog.log severity, args, 2
  r
rescue
  args.push "exception raised after #{"%d msecs" % (1000 * (Time.now - start)) }"
  Dlog.log severity, args, 2
  raise
end

#debug(*args, &block) ⇒ Object



231
232
233
# File 'lib/dlog.rb', line 231

def debug(*args, &block)
  benchmark :debug, args, &block
end

#error(*args, &block) ⇒ Object



221
222
223
# File 'lib/dlog.rb', line 221

def error(*args, &block)
  benchmark :error, args, &block
end

#info(*args, &block) ⇒ Object



228
229
230
# File 'lib/dlog.rb', line 228

def info(*args, &block)
  benchmark :info, args, &block
end

#warn(*args, &block) ⇒ Object



225
226
227
# File 'lib/dlog.rb', line 225

def warn(*args, &block)
  benchmark :warn, args, &block
end