class Spoom::Coverage::D3::Timeline::Runtimes

Public Class Methods

new(id, snapshots) click to toggle source
Calls superclass method Spoom::Coverage::D3::Timeline::new
# File lib/spoom/coverage/d3/timeline.rb, line 282
def initialize(id, snapshots)
  data = snapshots.map do |snapshot|
    {
      timestamp: snapshot.commit_timestamp,
      commit: snapshot.commit_sha,
      runtime: snapshot.duration.to_f / 1000.0 / 1000.0,
    }
  end
  super(id, data, [])
end

Public Instance Methods

plot() click to toggle source
# File lib/spoom/coverage/d3/timeline.rb, line 307
          def plot
            <<~JS
              #{x_scale}
              #{y_scale(
                min: '0',
                max: "d3.max(data_#{id}, (d) => d.runtime)",
                ticks: 'ticks(10)'
              )}
              #{area(y: 'd.runtime')}
              #{line(y: 'd.runtime')}
              #{points(y: 'd.runtime')}
              #{x_ticks}
              #{y_ticks(ticks: 'ticks(5)', format: 'd.toFixed(2) + "s"', padding: 40)}
                .call(g => g.selectAll(".tick:first-of-type text").remove())
            JS
          end
tooltip() click to toggle source
# File lib/spoom/coverage/d3/timeline.rb, line 294
          def tooltip
            <<~JS
              function tooltip_#{id}(d) {
                moveTooltip(d)
                  .html("commit <b>" + d.commit + "</b><br>"
                    + d3.timeFormat("%y/%m/%d")(parseDate(d.timestamp)) + "<br><br>"
                    + "<b>" + d.runtime + "</b>s<br><br>"
                    + "(sorbet user + system time)")
              }
            JS
          end