2015-09-23 00:31:37 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-09-23 00:31:37 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-09-23 00:31:37 +00:00
|
|
|
*
|
2018-05-11 02:06:46 +00:00
|
|
|
* @format
|
2018-06-20 07:35:29 +00:00
|
|
|
* @flow strict
|
2015-09-23 00:31:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2018-01-22 13:19:19 +00:00
|
|
|
const AUTO_SET_TIMESTAMP = -1;
|
|
|
|
const DUMMY_INSTANCE_KEY = 0;
|
2015-09-23 00:31:37 +00:00
|
|
|
|
2018-01-22 13:19:19 +00:00
|
|
|
const QuickPerformanceLogger = {
|
|
|
|
markerStart(
|
|
|
|
markerId: number,
|
|
|
|
instanceKey: number = DUMMY_INSTANCE_KEY,
|
|
|
|
timestamp: number = AUTO_SET_TIMESTAMP,
|
|
|
|
): void {
|
2015-09-23 00:31:37 +00:00
|
|
|
if (global.nativeQPLMarkerStart) {
|
2018-01-22 13:19:19 +00:00
|
|
|
global.nativeQPLMarkerStart(markerId, instanceKey, timestamp);
|
2015-09-23 00:31:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-01-22 13:19:19 +00:00
|
|
|
markerEnd(
|
|
|
|
markerId: number,
|
|
|
|
actionId: number,
|
|
|
|
instanceKey: number = DUMMY_INSTANCE_KEY,
|
|
|
|
timestamp: number = AUTO_SET_TIMESTAMP,
|
|
|
|
): void {
|
2015-09-23 00:31:37 +00:00
|
|
|
if (global.nativeQPLMarkerEnd) {
|
2018-01-22 13:19:19 +00:00
|
|
|
global.nativeQPLMarkerEnd(markerId, instanceKey, actionId, timestamp);
|
2015-09-23 00:31:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-01-22 13:19:19 +00:00
|
|
|
markerNote(
|
|
|
|
markerId: number,
|
|
|
|
actionId: number,
|
|
|
|
instanceKey: number = DUMMY_INSTANCE_KEY,
|
|
|
|
timestamp: number = AUTO_SET_TIMESTAMP,
|
|
|
|
): void {
|
2015-09-23 00:31:37 +00:00
|
|
|
if (global.nativeQPLMarkerNote) {
|
2018-01-22 13:19:19 +00:00
|
|
|
global.nativeQPLMarkerNote(markerId, instanceKey, actionId, timestamp);
|
2015-09-23 00:31:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-01-22 13:19:19 +00:00
|
|
|
markerTag(
|
|
|
|
markerId: number,
|
|
|
|
tag: string,
|
|
|
|
instanceKey: number = DUMMY_INSTANCE_KEY,
|
|
|
|
): void {
|
2017-02-16 19:30:39 +00:00
|
|
|
if (global.nativeQPLMarkerTag) {
|
2018-01-22 13:19:19 +00:00
|
|
|
global.nativeQPLMarkerTag(markerId, instanceKey, tag);
|
2017-02-16 19:30:39 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-01-22 13:19:19 +00:00
|
|
|
markerAnnotate(
|
|
|
|
markerId: number,
|
|
|
|
annotationKey: string,
|
|
|
|
annotationValue: string,
|
|
|
|
instanceKey: number = DUMMY_INSTANCE_KEY,
|
|
|
|
): void {
|
2017-02-16 19:30:39 +00:00
|
|
|
if (global.nativeQPLMarkerAnnotate) {
|
2018-01-22 13:19:19 +00:00
|
|
|
global.nativeQPLMarkerAnnotate(
|
|
|
|
markerId,
|
|
|
|
instanceKey,
|
|
|
|
annotationKey,
|
|
|
|
annotationValue,
|
|
|
|
);
|
2017-02-16 19:30:39 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-01-22 13:19:19 +00:00
|
|
|
markerCancel(
|
|
|
|
markerId: number,
|
|
|
|
instanceKey?: number = DUMMY_INSTANCE_KEY,
|
|
|
|
): void {
|
2015-09-23 00:31:37 +00:00
|
|
|
if (global.nativeQPLMarkerCancel) {
|
2018-01-22 13:19:19 +00:00
|
|
|
global.nativeQPLMarkerCancel(markerId, instanceKey);
|
2015-09-23 00:31:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-08 15:24:47 +00:00
|
|
|
markerPoint(
|
|
|
|
markerId: number,
|
|
|
|
name: string,
|
|
|
|
instanceKey: number = DUMMY_INSTANCE_KEY,
|
|
|
|
timestamp: number = AUTO_SET_TIMESTAMP,
|
|
|
|
): void {
|
|
|
|
if (global.nativeQPLMarkerPoint) {
|
|
|
|
global.nativeQPLMarkerPoint(markerId, name, instanceKey, timestamp);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-01-22 13:19:19 +00:00
|
|
|
currentTimestamp(): number {
|
2015-09-23 00:31:37 +00:00
|
|
|
if (global.nativeQPLTimestamp) {
|
|
|
|
return global.nativeQPLTimestamp();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = QuickPerformanceLogger;
|