Module: SSO::Benchmarking
- Included in:
- Client::Authentications::Passport, Client::PassportVerifier, Client::Warden::Hooks::AfterFetch, Client::Warden::Strategies::Passport, Server::Passport, Server::Warden::Strategies::Passport
- Defined in:
- lib/sso/benchmarking.rb
Overview
Helper to log results of benchmarks.
Instance Method Summary collapse
Methods included from Meter
#caller_name, #metric, #timing, #track
Methods included from Logging
#debug, #error, #fatal, #info, #logger, #progname, #warn
Instance Method Details
#benchmark(name: nil, metric: nil, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/sso/benchmarking.rb', line 7 def benchmark(name: nil, metric: nil, &block) return unless block_given? result = nil seconds = Benchmark.realtime do result = block.call end milliseconds = (seconds * 1000).round debug { "#{name || metric || 'Benchmark'} took #{milliseconds}ms" } timing key: metric, value: milliseconds if metric result end |