2015-09-23 00:31:37 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
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
|
|
|
*
|
|
|
|
* @providesModule QuickPerformanceLogger
|
2018-01-22 13:19:19 +00:00
|
|
|
* @flow
|
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-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;
|