mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: profiling setup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Button, EventData, Page, Switch, View, getViewById, Observable, Label, PropertyChangeData } from '@nativescript/core';
|
||||
import { jamieProfiler } from '@nativescript/core/profiling/jamie';
|
||||
|
||||
export function navigatingTo(args: EventData) {
|
||||
const page = <Page>args.object;
|
||||
@@ -47,11 +48,22 @@ export class DemoModel extends Observable {
|
||||
|
||||
this.target.addEventListener(Observable.propertyChangeEvent, onPropertyChange, null);
|
||||
|
||||
jamieProfiler.flush();
|
||||
|
||||
console.log('BEGIN PROFILE');
|
||||
const time = profile(() => {
|
||||
for (let i = 0; i < 1000000; i++) {
|
||||
this.target.setProperty(propName, i);
|
||||
}
|
||||
});
|
||||
console.log('END PROFILE');
|
||||
|
||||
console.log(
|
||||
jamieProfiler
|
||||
.report(jamieProfiler.flush())
|
||||
.map(([key, value]) => `${key}: ${value} ms`)
|
||||
.join('\n')
|
||||
);
|
||||
|
||||
this.target.removeEventListener(Observable.propertyChangeEvent, onPropertyChange, null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user