[Groonga-commit] groonga/grntest [master] Add a method to measure elapsed time

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 8日 (水) 15:16:29 JST


Kouhei Sutou	2012-08-08 15:16:29 +0900 (Wed, 08 Aug 2012)

  New Revision: 5e7a2553802fdb3032338c31fcb06ec8b80acac1
  https://github.com/groonga/grntest/commit/5e7a2553802fdb3032338c31fcb06ec8b80acac1

  Log:
    Add a method to measure elapsed time

  Modified files:
    lib/groonga/tester.rb

  Modified: lib/groonga/tester.rb (+10 -3)
===================================================================
--- lib/groonga/tester.rb    2012-08-08 15:14:37 +0900 (5488bbc)
+++ lib/groonga/tester.rb    2012-08-08 15:16:29 +0900 (23d56da)
@@ -267,6 +267,13 @@ module Groonga
         @actual = nil
         @expected = nil
       end
+
+      def measure
+        start_time = Time.now
+        yield
+      ensure
+        @elapsed_time = Time.now - start_time
+      end
     end
 
     class TestRunner
@@ -285,9 +292,9 @@ module Groonga
         test_name = @test_script_path.basename.to_s
         result = TestResult.new(test_name)
         reporter.start_test(test_name)
-        started_time = Time.now
-        result.actual = run_groonga_script
-        result.elapsed_time = Time.now - started_time
+        result.measure do
+          result.actual = run_groonga_script
+        end
         result.actual = normalize_result(result.actual)
         result.expected = read_expected_result
         if result.expected
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index