rtyler/statsd — comment on commit f7c5375fccd993b380a799af607d200d2ef298c4
File:  line 0
By redterror:

One more suggestion on this, and I recognize this might be a api shift for the #timing method, but you might do something vaguely like:

```ruby
def timing(stat, time = nil, sample_rate = 1)
rv = nil
if block_given?
start_time = Time.now.to_f
rv = yield
time = ((Time.now.to_f - start_time) * 1000).floor
end
rv = send_stats("#{stat}:#{time}|ms", sample_rate)

return rv
end
```

This way you can do in your caller

bar = Statsd.timing("slow_function"){ calc(foo) + calc(baz) }