MCPcopy
hub / github.com/ampproject/amphtml / tick

Method tick

src/service/performance-impl.js:799–835  ·  view source on GitHub ↗

* Ticks a timing event. * * @param {TickLabel_Enum} label The variable name as it will be reported. * See TICKEVENTS.md for available metrics, and edit this file * when adding a new metric. * @param {number=} opt_delta The delta. Call tickDelta instead of setting * this

(label, opt_delta, opt_value)

Source from the content-addressed store, hash-verified

797 * @param {number=} opt_value The value to use. Overrides default calculation.
798 */
799 tick(label, opt_delta, opt_value) {
800 devAssert(
801 opt_delta == undefined || opt_value == undefined,
802 'You may not set both opt_delta and opt_value.'
803 );
804
805 const data = {'label': label};
806 let delta;
807
808 if (opt_delta != undefined) {
809 data['delta'] = delta = Math.max(opt_delta, 0);
810 } else if (opt_value != undefined) {
811 data['value'] = opt_value;
812 } else {
813 // Marking only makes sense for non-overridden values (and no deltas).
814 this.mark(label);
815 delta = this.win.performance.now();
816 data['value'] = this.timeOrigin_ + delta;
817 }
818
819 // Emit events. Used by `amp performance`.
820 this.win.dispatchEvent(
821 createCustomEvent(
822 this.win,
823 'perf',
824 /** @type {JsonObject} */ ({label, delta})
825 )
826 );
827
828 if (this.isMessagingReady_ && this.isPerformanceTrackingOn_) {
829 this.viewer_.sendMessage('tick', data);
830 } else {
831 this.queueTick_(data);
832 }
833
834 this.metrics_.signal(label, delta);
835 }
836
837 /**
838 * Add browser performance timeline entries for simple ticks.

Callers 15

constructorMethod · 0.95
coreServicesAvailableMethod · 0.95
onload_Method · 0.95
processEntryMethod · 0.95
tickDeltaMethod · 0.95
test-action.jsFile · 0.80
test-loader.jsFile · 0.80
test-vsync.jsFile · 0.80

Calls 7

markMethod · 0.95
queueTick_Method · 0.95
devAssertFunction · 0.90
createCustomEventFunction · 0.90
nowMethod · 0.80
sendMessageMethod · 0.45
signalMethod · 0.45

Tested by

no test coverage detected