Skip to content

Commit 4ba82e8

Browse files
author
vakrilov
committed
Startup page to measure ng bootstrap
1 parent 17b6d0a commit 4ba82e8

15 files changed

+347
-24
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ ng-sample/app/nativescript-angular
3737

3838
perf-test/platforms
3939
perf-test/hooks
40-
ng-sample/app/**/*.js
40+
perf-test/app/**/*.js
41+
perf-test/app/**/*.ngfactory.ts
42+
perf-test/app/**/*.ngsummary.json
4143

4244
# IDEs and editors
4345
/.idea

perf-test/app/bootstrap-ng-app.aot.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { start } from "tns-core-modules/profiling";
2+
start("bootstrap-ng-app");
3+
4+
// this import should be first in order to load some required settings (like globals and reflect-metadata)
5+
import { platformNativeScript } from "nativescript-angular/platform-static";
6+
7+
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
8+
import { APP_ROOT_VIEW } from "nativescript-angular/platform-providers";
9+
import { AppModuleNgFactory } from "./app.module.ngfactory";
10+
import { topmost } from "tns-core-modules/ui/frame"
11+
12+
const rootPage = topmost().currentPage;
13+
const rootViewProvider = { provide: APP_ROOT_VIEW, useValue: rootPage };
14+
const platform = platformNativeScript({ bootInExistingPage: true }, [rootViewProvider]);
15+
16+
platform.bootstrapModuleFactory(AppModuleNgFactory);

perf-test/app/bootstrap-ng-app.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { start } from "tns-core-modules/profiling";
2+
start("bootstrap-ng-app");
3+
4+
// this import should be first in order to load some required settings (like globals and reflect-metadata)
5+
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
6+
import { APP_ROOT_VIEW } from "nativescript-angular/platform-providers";
7+
import { AppModule } from "./app.module";
8+
import { topmost } from "tns-core-modules/ui/frame"
9+
10+
const rootPage = topmost().currentPage;
11+
const rootViewProvider = { provide: APP_ROOT_VIEW, useValue: rootPage };
12+
const platform = platformNativeScriptDynamic({ bootInExistingPage: true }, [rootViewProvider]);
13+
14+
platform.bootstrapModule(AppModule);

perf-test/app/home.component.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import { Component } from "@angular/core";
1+
import { Component, AfterViewChecked } from "@angular/core";
2+
import { stop } from "tns-core-modules/profiling";
23

34
@Component({
45
moduleId: module.id,
56
selector: "ns-home",
67
templateUrl: "./home.component.html",
78
})
8-
export class HomeComponent { }
9+
export class HomeComponent implements AfterViewChecked {
10+
isLoaded = false;
11+
ngAfterViewChecked() {
12+
if (!this.isLoaded) {
13+
stop("bootstrap-ng-app");
14+
this.isLoaded = true;
15+
}
16+
}
17+
}

perf-test/app/main.aot.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
// this import should be first in order to load some required settings (like globals and reflect-metadata)
21
import { enable } from "tns-core-modules/profiling";
32
enable();
43

5-
import { platformNativeScript } from "nativescript-angular/platform-static";
4+
import * as application from "tns-core-modules/application";
5+
import { Page } from "tns-core-modules/ui/page";
6+
import { Button } from "tns-core-modules/ui/button";
67

7-
import { AppModuleNgFactory } from "./app.module.ngfactory";
8+
application.start({
9+
create: (): Page => {
10+
const page = new Page();
11+
const startBtn = new Button();
12+
startBtn.text = "start";
13+
startBtn.on("tap", () => {
14+
require("./bootstrap-ng-app.aot");
15+
})
816

9-
platformNativeScript().bootstrapModuleFactory(AppModuleNgFactory);
17+
page.content = startBtn;
18+
return page;
19+
}
20+
});

perf-test/app/main.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
// this import should be first in order to load some required settings (like globals and reflect-metadata)
21
import { enable } from "tns-core-modules/profiling";
32
enable();
43

5-
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
4+
import * as application from "tns-core-modules/application";
5+
import { Page } from "tns-core-modules/ui/page";
6+
import { Button } from "tns-core-modules/ui/button";
67

7-
import { AppModule } from "./app.module";
8+
application.start({
9+
create: (): Page => {
10+
const page = new Page();
11+
const startBtn = new Button();
12+
startBtn.text = "start";
13+
startBtn.on("tap", () => {
14+
require("./bootstrap-ng-app");
15+
})
816

9-
platformNativeScriptDynamic().bootstrapModule(AppModule);
17+
page.content = startBtn;
18+
return page;
19+
}
20+
});

perf-test/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"v8Flags": "--expose_gc"
44
},
55
"main": "main.js",
6+
"_main": "main.aot.js",
67
"name": "tns-template-hello-world-ng",
78
"version": "3.0.0"
89
}

perf-test/app/renderer/renderer-test.component.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@
99
</WrapLayout>
1010
<ScrollView row="1">
1111
<StackLayout>
12-
<FlexboxLayout *ngFor="let item of items" flexDirection="row" flexWrap="wrap" alignItems="center" borderWidth="0 0 1 0" borderColor="#EEEEEE">
13-
<Image [src]="item.icon" flexGrow="0" flexShrink="1" margin="6 4 4 4" borderWidth="1" borderColor="gray" borderRadius="16"
14-
width="32" height="32"></Image>
15-
<Label [text]="item.title" flexGrow="1" flexShrink="0" width="0" margin="1 4 0 0"></Label>
16-
<Label [text]="item.body" textWrap="true" width="100%" margin="4 4 6 4" fontSize="11"></Label>
17-
<Image src="~/icons/thumbsdown.png" width="18" height="18" margin="4"></Image>
18-
<Label [text]="item.up" flexGrow="1" flexShrink="0" width="0" fontSize="13"></Label>
19-
<Image src="~/icons/thumbsup.png" width="18" height="18" margin="4"></Image>
20-
<Label [text ]="item.down" flexGrow="1" flexShrink="0" width="0" fontSize="13"></Label>
21-
</FlexboxLayout>
12+
<flexbox-item *ngFor="let item of items" [item]="item"></flexbox-item>
2213
</StackLayout>
2314
</ScrollView>
2415
</GridLayout>

perf-test/app/renderer/renderer-test.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Component } from '@angular/core';
22
import { GC } from "tns-core-modules/utils/utils";
3-
import { dumpProfiles, resetProfiles } from "tns-core-modules/profiling";
3+
import {
4+
// resetProfiles,
5+
dumpProfiles
6+
} from "tns-core-modules/profiling";
47

58
const titles = ["Etiam lacinia", "Imperdiet ante", "A interdum", "Quisque tempus", "Sodales viverra"];
69
const bodies = [
@@ -65,6 +68,6 @@ export class RendererTestComponent {
6568
}
6669

6770
reset(){
68-
resetProfiles()
71+
// resetProfiles()
6972
}
7073
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require("application");
2+
require("ui/frame");
3+
require("ui/frame/activity");

perf-test/app/vendor-platform.ios.ts

Whitespace-only changes.

perf-test/app/vendor.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require("./vendor-platform");
2+
3+
require("reflect-metadata");
4+
require("@angular/platform-browser");
5+
require("@angular/core");
6+
require("@angular/common");
7+
require("@angular/forms");
8+
require("@angular/http");
9+
require("@angular/router");
10+
11+
require("nativescript-angular/platform-static");
12+
require("nativescript-angular/forms");
13+
require("nativescript-angular/router");

perf-test/package.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,33 @@
2626
"reflect-metadata": "~0.1.8",
2727
"rxjs": "~5.3.0",
2828
"tns-core-modules": "next",
29+
"tns-ios": "^3.0.0",
2930
"zone.js": "~0.8.2"
3031
},
3132
"devDependencies": {
33+
"@angular/compiler-cli": "~4.1.0",
34+
"@ngtools/webpack": "1.3.1",
3235
"babel-traverse": "6.24.1",
3336
"babel-types": "6.24.1",
3437
"babylon": "6.17.1",
38+
"copy-webpack-plugin": "~4.0.1",
39+
"extract-text-webpack-plugin": "~2.1.0",
3540
"lazy": "1.0.11",
41+
"nativescript-css-loader": "~0.26.0",
3642
"nativescript-dev-typescript": "~0.4.0",
37-
"typescript": "~2.2.1"
43+
"nativescript-dev-webpack": "^0.5.0",
44+
"raw-loader": "~0.5.1",
45+
"resolve-url-loader": "~2.0.2",
46+
"typescript": "~2.2.1",
47+
"webpack": "~2.5.1",
48+
"webpack-sources": "~0.2.3"
49+
},
50+
"scripts": {
51+
"ns-bundle": "ns-bundle",
52+
"start-android-bundle": "npm run ns-bundle --android --start-app",
53+
"start-ios-bundle": "npm run ns-bundle --ios --start-app",
54+
"build-android-bundle": "npm run ns-bundle --android --build-app",
55+
"build-ios-bundle": "npm run ns-bundle --ios --build-app",
56+
"ngc": "ngc -p ./tsconfig.aot.json"
3857
}
3958
}

perf-test/tsconfig.aot.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"extends": "./tsconfig",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"paths": {
6+
"application": ["node_modules/tns-core-modules/application"],
7+
"application-settings": ["node_modules/tns-core-modules/application-settings"],
8+
"camera": ["node_modules/tns-core-modules/camera"],
9+
"color": ["node_modules/tns-core-modules/color"],
10+
"connectivity": ["node_modules/tns-core-modules/connectivity"],
11+
"console": ["node_modules/tns-core-modules/console"],
12+
"data/*": ["node_modules/tns-core-modules/data/*"],
13+
"fetch": ["node_modules/tns-core-modules/fetch"],
14+
"file-system": ["node_modules/tns-core-modules/file-system"],
15+
"fps-meter": ["node_modules/tns-core-modules/fps-meter"],
16+
"globals": ["node_modules/tns-core-modules/globals"],
17+
"http": ["node_modules/tns-core-modules/http"],
18+
"image-asset": ["node_modules/tns-core-modules/image-asset"],
19+
"image-source": ["node_modules/tns-core-modules/image-source"],
20+
"location": ["node_modules/tns-core-modules/location"],
21+
"platform": ["node_modules/tns-core-modules/platform"],
22+
"text": ["node_modules/tns-core-modules/text"],
23+
"timer": ["node_modules/tns-core-modules/timer"],
24+
"trace": ["node_modules/tns-core-modules/trace"],
25+
"ui/*": ["node_modules/tns-core-modules/ui/*"],
26+
"utils/*": ["node_modules/tns-core-modules/utils/*"],
27+
"xhr": ["node_modules/tns-core-modules/xhr"],
28+
"xml": ["node_modules/tns-core-modules/xml"]
29+
},
30+
"skipLibCheck": true
31+
},
32+
"exclude": [
33+
"node_modules",
34+
"platforms"
35+
],
36+
"angularCompilerOptions": {
37+
"skipMetadataEmit": true,
38+
"genDir": "./"
39+
}
40+
}

0 commit comments

Comments
 (0)