Skip to content

Commit a5fc1f9

Browse files
committed
ng-sample profiling updated for bundled scripts
1 parent 5870849 commit a5fc1f9

File tree

4 files changed

+80
-75
lines changed

4 files changed

+80
-75
lines changed

ng-sample/app/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import "globals";
22
// import "./modules";
33
global.registerModule("./main-page", function () { return require("./main-page"); });
44

5-
import * as profiling from "./profiling";
6-
profiling.start('application-start');
5+
//import * as profiling from "./profiling";
6+
//profiling.start('application-start');
77
import application = require("application");
88

99
//TODO: hide this in a separate module e.g. "angular-application"

ng-sample/app/profiling.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ interface TimerInfo {
2525
currentStart: number;
2626
}
2727

28-
var timers = new Map<string, TimerInfo>();
28+
if (!global.timers) {
29+
global.timers = new Map<string, TimerInfo>();
30+
}
2931
export function start(name: string): void {
3032
if (!ENABLE_PROFILING) {
3133
return;
3234
}
3335

3436
var info: TimerInfo;
35-
if (timers.has(name)) {
36-
info = timers.get(name);
37+
if (global.timers.has(name)) {
38+
info = global.timers.get(name);
3739
if (info.currentStart != 0) {
3840
throw new Error(`Timer already started: ${name}`);
3941
}
@@ -45,7 +47,7 @@ export function start(name: string): void {
4547
count: 0,
4648
currentStart: time()
4749
};
48-
timers.set(name, info);
50+
global.timers.set(name, info);
4951
}
5052
}
5153

@@ -66,11 +68,11 @@ export function stop(name: string) {
6668
var info = pauseInternal(name);
6769
console.log(`---- [${name}] STOP total: ${info.totalTime} count:${info.count}`);
6870

69-
timers.delete(name);
71+
global.timers.delete(name);
7072
}
7173

7274
function pauseInternal(name: string): TimerInfo {
73-
var info = timers.get(name);
75+
var info = global.timers.get(name);
7476
if (!info) {
7577
throw new Error(`No timer started: ${name}`);
7678
}

ng-sample/app/starter.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
//if (!global.timers) {
2-
//global.timers = new Map();
3-
//}
1+
declare var java: any;
2+
declare var CACurrentMediaTime: any;
43

5-
//function time() {
6-
//if (global.android) {
7-
//return java.lang.System.nanoTime() / 1000000; // 1 ms = 1000000 ns
8-
//}
9-
//else {
10-
//return CACurrentMediaTime() * 1000;
11-
//}
12-
//}
4+
if (!global.timers) {
5+
global.timers = new Map();
6+
}
137

14-
//var timerEntry = {
15-
//totalTime: 0,
16-
//count: 0,
17-
//currentStart: time()
18-
//};
8+
function time() {
9+
if (global.android) {
10+
return java.lang.System.nanoTime() / 1000000; // 1 ms = 1000000 ns
11+
}
12+
else {
13+
return CACurrentMediaTime() * 1000;
14+
}
15+
}
1916

20-
//global.timers.set("application-start", timerEntry);
17+
var timerEntry = {
18+
totalTime: 0,
19+
count: 0,
20+
currentStart: time()
21+
};
22+
23+
global.timers.set("application-start", timerEntry);
2124

2225
import "./app.js"

ng-sample/package.json

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
{
2-
"name": "tns-template-hello-world",
3-
"main": "app.js",
4-
"version": "1.1.0",
5-
"author": "Telerik <support@telerik.com>",
6-
"description": "Nativescript hello-world project template",
7-
"license": "BSD",
8-
"keywords": [
9-
"telerik",
10-
"mobile",
11-
"nativescript",
12-
"{N}",
13-
"tns",
14-
"appbuilder",
15-
"template"
16-
],
17-
"repository": {
18-
"type": "git",
19-
"url": "git://github.com/NativeScript/template-hello-world.git"
20-
},
21-
"bugs": {
22-
"url": "https://github.com/NativeScript/template-hello-world/issues"
23-
},
24-
"homepage": "https://github.com/NativeScript/template-hello-world",
25-
"dependencies": {
26-
"@reactivex/rxjs": "5.0.0-alpha.7",
27-
"parse5": "1.4.2",
28-
"punycode": "1.3.2",
29-
"querystring": "0.2.0",
30-
"url": "0.10.3",
31-
"reflect-metadata": "0.1.2",
32-
"zone.js": "0.5.8"
33-
},
34-
"devDependencies": {
35-
"grunt": "0.4.5",
36-
"grunt-contrib-clean": "0.6.0",
37-
"grunt-contrib-copy": "0.8.0",
38-
"grunt-shell": "1.1.2",
39-
"grunt-ts": "5.0.0-beta.5",
40-
"nativescript-dev-typescript": "^0.2.2",
41-
"shelljs": "^0.5.3",
42-
"typescript": "^1.7.3",
43-
"webpack": "^1.12.9"
44-
},
45-
"nativescript": {
46-
"id": "org.nativescript.ngsample",
47-
"tns-android": {
48-
"version": "1.5.0"
49-
}
50-
}
51-
}
2+
"name": "tns-template-hello-world",
3+
"main": "app.js",
4+
"version": "1.1.0",
5+
"author": "Telerik <support@telerik.com>",
6+
"description": "Nativescript hello-world project template",
7+
"license": "BSD",
8+
"keywords": [
9+
"telerik",
10+
"mobile",
11+
"nativescript",
12+
"{N}",
13+
"tns",
14+
"appbuilder",
15+
"template"
16+
],
17+
"repository": {
18+
"type": "git",
19+
"url": "git://github.com/NativeScript/template-hello-world.git"
20+
},
21+
"bugs": {
22+
"url": "https://github.com/NativeScript/template-hello-world/issues"
23+
},
24+
"homepage": "https://github.com/NativeScript/template-hello-world",
25+
"dependencies": {
26+
"@reactivex/rxjs": "5.0.0-alpha.7",
27+
"parse5": "1.4.2",
28+
"punycode": "1.3.2",
29+
"querystring": "0.2.0",
30+
"url": "0.10.3",
31+
"reflect-metadata": "0.1.2",
32+
"zone.js": "0.5.8"
33+
},
34+
"devDependencies": {
35+
"grunt": "0.4.5",
36+
"grunt-contrib-clean": "0.6.0",
37+
"grunt-contrib-copy": "0.8.0",
38+
"grunt-shell": "1.1.2",
39+
"grunt-ts": "5.0.0-beta.5",
40+
"nativescript-dev-typescript": "^0.2.2",
41+
"shelljs": "^0.5.3",
42+
"typescript": "^1.7.3",
43+
"webpack": "^1.12.9"
44+
},
45+
"nativescript": {
46+
"id": "org.nativescript.ngsample",
47+
"tns-android": {
48+
"version": "1.5.0"
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)