mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Add resetProfiles method
This commit is contained in:
5
tns-core-modules/profiling/profiling.d.ts
vendored
5
tns-core-modules/profiling/profiling.d.ts
vendored
@ -67,6 +67,11 @@ export declare function profile(name?: string): MethodDecorator;
|
|||||||
*/
|
*/
|
||||||
export declare function dumpProfiles(): void;
|
export declare function dumpProfiles(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the timers for all methods instrumented with profile decorator.
|
||||||
|
*/
|
||||||
|
export function resetProfiles(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts android cpu profiling.
|
* Starts android cpu profiling.
|
||||||
* @param name Name of the cpu profiling session.
|
* @param name Name of the cpu profiling session.
|
||||||
|
@ -16,7 +16,7 @@ const timers: { [ index: string ]: TimerInfo } = {};
|
|||||||
const anyGlobal = <any>global;
|
const anyGlobal = <any>global;
|
||||||
const profileNames: string[] = [];
|
const profileNames: string[] = [];
|
||||||
|
|
||||||
let ENABLED = true;
|
let ENABLED = false;
|
||||||
let nativeTimeFunc: () => number;
|
let nativeTimeFunc: () => number;
|
||||||
|
|
||||||
export function enable() {
|
export function enable() {
|
||||||
@ -167,6 +167,20 @@ export function dumpProfiles(): void {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resetProfiles(): void {
|
||||||
|
profileNames.forEach(function (name) {
|
||||||
|
const info = timers[name];
|
||||||
|
|
||||||
|
if (info) {
|
||||||
|
if (!info.isRunning) {
|
||||||
|
timers[name] = undefined;
|
||||||
|
} else {
|
||||||
|
console.log("---- timer with name [" + name + "] is currently running and won't be reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function startCPUProfile(name: string) {
|
export function startCPUProfile(name: string) {
|
||||||
if (!ENABLED) {
|
if (!ENABLED) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user