Module: Jets::Timing
- Extended by:
- ActiveSupport::Concern
- Included in:
- Builders::CodeBuilder, Cfn::Ship, Commands::Build, Commands::Deploy
- Defined in:
- lib/jets/timing.rb,
lib/jets/timing/report.rb
Defined Under Namespace
Classes: Report
Constant Summary collapse
- RECORD_LOG_PATH =
"#{Jets.build_root}/timing/records.log"
Class Method Summary collapse
-
.clear ⇒ Object
Clear out all timing data.
- .report ⇒ Object
Instance Method Summary collapse
Class Method Details
.clear ⇒ Object
Clear out all timing data
39 40 41 42 |
# File 'lib/jets/timing.rb', line 39 def self.clear return unless File.exist?(RECORD_LOG_PATH) FileUtils.cp("/dev/null", RECORD_LOG_PATH) end |
Instance Method Details
#record_data(meth, type) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jets/timing.rb', line 19 def record_data(meth, type) # https://stackoverflow.com/questions/17267935/display-time-down-to-milliseconds-in-ruby-1-8-7 # Record time in milliseconds unit so we can calculate time differences later time = (Time.now.to_f * 1000.0).to_i JSON.dump( class: self.class.name, meth: meth, time: time, type: type, ) end |
#record_log(meth, type) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/jets/timing.rb', line 31 def record_log(meth, type) data = record_data(meth, type) path = Timing::RECORD_LOG_PATH FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'a') {|f| f.write(data + "\n") } end |