-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
index.native.js
56 lines (45 loc) · 1.1 KB
/
index.native.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* eslint-disable no-unused-vars */
import perf from '@react-native-firebase/perf';
import * as Environment from '../Environment/Environment';
import Log from '../Log';
const traceMap = {};
/**
* @param {String} customEventName
*/
function startTrace(customEventName) {
const start = global.performance.now();
if (Environment.isDevelopment()) {
return;
}
if (traceMap[customEventName]) {
return;
}
perf().startTrace(customEventName)
.then((trace) => {
traceMap[customEventName] = {
trace,
start,
};
});
}
/**
* @param {String} customEventName
*/
function stopTrace(customEventName) {
const stop = global.performance.now();
if (Environment.isDevelopment()) {
return;
}
const {trace, start} = traceMap[customEventName];
if (!trace) {
return;
}
trace.stop();
// Uncomment to inspect logs on release builds
// Log.info(`sidebar_loaded: ${stop - start} ms`, true);
delete traceMap[customEventName];
}
export default {
startTrace,
stopTrace,
};