kosmatov/sidekiq-benchmark — pull request #8 by ixti (2014-03-12 01:30:03+00:00)
Title: Improve nested benchmark API

API is 100% compatible with original one, and extend it with 3 new methods:

- `Benchmark#[]` returns nested timing report
- `Benchmark#[]=` privides a clean API to set timing value
- `Benchmark#measure` benchmarks given block

USAGE:

class ArticleElesticUpdater
def perform(operation, id)
send(operation, id)
end

def update(id)
benchmark do |bm|
article = bm.measure(:find_article) { Article.find id }
bm.measure(:update_index) { article.update_elastic_index }
end
end

def delete(id)
benchmark do |bm|
bm.measure(:delete_index) { Article.delete_elastic_index id }
end
end
end