summaryrefslogtreecommitdiff
path: root/tool/lrama/lib/lrama/report/duration.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tool/lrama/lib/lrama/report/duration.rb')
-rw-r--r--tool/lrama/lib/lrama/report/duration.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/tool/lrama/lib/lrama/report/duration.rb b/tool/lrama/lib/lrama/report/duration.rb
new file mode 100644
index 0000000000..7afe284f1a
--- /dev/null
+++ b/tool/lrama/lib/lrama/report/duration.rb
@@ -0,0 +1,25 @@
+module Lrama
+ class Report
+ module Duration
+ def self.enable
+ @_report_duration_enabled = true
+ end
+
+ def self.enabled?
+ !!@_report_duration_enabled
+ end
+
+ def report_duration(method_name)
+ time1 = Time.now.to_f
+ result = yield
+ time2 = Time.now.to_f
+
+ if Duration.enabled?
+ puts sprintf("%s %10.5f s", method_name, time2 - time1)
+ end
+
+ return result
+ end
+ end
+ end
+end