All files / shared Performance.js

50% Statements 4/8
54.55% Branches 6/11
100% Functions 3/3
50% Lines 4/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                  39x 39x       26x           13x              
/**
 * Wrapper around the performance markers api
 *
 * @class Performance
 */
import { hasOwn } from './utils'
 
export class Performance {
  static hasPerformanceApi () {
    const p = typeof window !== 'undefined' && hasOwn(window, 'performance')
    return p && p.mark && p.measure && p.clearMarks && p.clearMeasures
  }
 
  static mark (tag) {
    Iif (Performance.hasPerformanceApi()) {
      window.performance.mark(tag)
    }
  }
 
  static measure (name, from, to) {
    Iif (Performance.hasPerformanceApi()) {
      window.performance.measure(name, from, to)
      window.performance.clearMarks(from)
      window.performance.clearMarks(to)
    }
  }
}