Sha256: 67c143eba47b3836f859ffab44553ed77647a8fe295ccc224bff8c4baba7556b

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

#= require trix/inspector/view

Trix.Inspector.registerView class extends Trix.Inspector.View
  title: "Performance"
  template: "performance"

  constructor: ->
    super
    {@documentView} = @compositionController

    @data = {}
    @track("documentView.render")
    @track("documentView.sync")
    @track("documentView.garbageCollectCachedViews")
    @track("composition.replaceHTML")

    @render()

  track: (methodPath) ->
    @data[methodPath] = calls: 0, total: 0, mean: 0, max: 0, last: 0

    [propertyNames..., methodName] = methodPath.split(".")
    object = this
    for propertyName in propertyNames
      object = object[propertyName]

    original = object[methodName]
    object[methodName] = =>
      started = now()
      result = original.apply(object, arguments)
      timing = now() - started
      @record(methodPath, timing)
      result

  record: (methodPath, timing) ->
    data = @data[methodPath]
    data.calls += 1
    data.total += timing
    data.mean = data.total / data.calls
    data.max = timing if timing > data.max
    data.last = timing
    @render()

  round: (ms) ->
    Math.round(ms * 1000) / 1000

  now =
    if window.performance?.now?
      -> performance.now()
    else
      -> new Date().getTime()

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vapid-0.1.3 lib/vapid/vendor/trix/src/trix/inspector/views/performance_view.coffee
vapid-0.1.2 lib/vapid/vendor/trix/src/trix/inspector/views/performance_view.coffee
vapid-0.1.1 lib/vapid/vendor/trix/src/trix/inspector/views/performance_view.coffee
vapid-0.1.0 lib/vapid/vendor/trix/src/trix/inspector/views/performance_view.coffee