Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Log slow rspec examples

Just a quick monkey patch...

   1  
   2  module Spec::Example
   3    module ExampleMethods
   4      THRESHOLD_TO_LOG = 500 # ms
   5      
   6      alias :execute_without_timing :execute
   7      def execute_with_timing(options)
   8        start_time = Time.now
   9        execute_without_timing(options)
  10        duration_ms = (Time.now - start_time) * 1000
  11        if (duration_ms > THRESHOLD_TO_LOG)
  12          print "(#{sprintf("%.3fms", duration_ms)} - #{_example.description}) "
  13        end
  14      end
  15      alias :execute :execute_with_timing
  16    end
  17  end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS