mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
definitions fixed
This commit is contained in:
2
apps/perf-tests/LargeObjectArrayMemoryLeakTest/app.ts
Normal file
2
apps/perf-tests/LargeObjectArrayMemoryLeakTest/app.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import application = require("application");
|
||||
application.mainModule = "app/LargeObjectArrayMemoryLeakTest/mainPage";
|
||||
55
apps/perf-tests/LargeObjectArrayMemoryLeakTest/mainPage.ts
Normal file
55
apps/perf-tests/LargeObjectArrayMemoryLeakTest/mainPage.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import pagesModule = require("ui/page");
|
||||
import stackLayoutModule = require("ui/layouts/stack-layout");
|
||||
import buttonModule = require("ui/button");
|
||||
import labelModule = require("ui/label");
|
||||
import nativeCallsWrapper = require("app/native-calls-wrapper");
|
||||
import enums = require("ui/enums");
|
||||
|
||||
export function createPage() {
|
||||
var OBJECTS_COUNT = 10000;
|
||||
|
||||
var mainStackLayout = new stackLayoutModule.StackLayout();
|
||||
mainStackLayout.orientation = enums.Orientation.vertical;
|
||||
|
||||
var label = new labelModule.Label();
|
||||
label.width = 500;
|
||||
mainStackLayout.addChild(label);
|
||||
if (label.ios) {// Hack for an iOS Arrange problem
|
||||
label.height = 80;
|
||||
}
|
||||
|
||||
var startButton = new buttonModule.Button();
|
||||
startButton.height = 50;
|
||||
startButton.width = 200;
|
||||
startButton.text = "Allocate memory";
|
||||
var startButtonClickHandler = function () {
|
||||
allocateMemory();
|
||||
};
|
||||
startButton.on(buttonModule.knownEvents.tap, startButtonClickHandler);
|
||||
|
||||
var stopButton = new buttonModule.Button();
|
||||
stopButton.height = 50;
|
||||
stopButton.width = 200;
|
||||
stopButton.text = "Clear memory";
|
||||
var stopButtonClickHandler = function () {
|
||||
nativeCallsWrapper.forceGarbageCollection();
|
||||
};
|
||||
stopButton.on(buttonModule.knownEvents.tap, stopButtonClickHandler);
|
||||
|
||||
mainStackLayout.addChild(startButton);
|
||||
mainStackLayout.addChild(stopButton);
|
||||
|
||||
var allocateMemory = function () {
|
||||
var datesArray = [];
|
||||
var i;
|
||||
for (i = 0; i < OBJECTS_COUNT; i++) {
|
||||
var date = nativeCallsWrapper.createNativeDate();
|
||||
datesArray.push(date);
|
||||
}
|
||||
};
|
||||
|
||||
var page = new pagesModule.Page();
|
||||
page.content = mainStackLayout;
|
||||
return page;
|
||||
}
|
||||
//export var Page = page;
|
||||
@@ -0,0 +1,9 @@
|
||||
export function forceGarbageCollection(): void {
|
||||
gc();
|
||||
}
|
||||
|
||||
var javaDate = java.util.Date;
|
||||
|
||||
export function createNativeDate(): any {
|
||||
return new javaDate();
|
||||
}
|
||||
4
apps/perf-tests/LargeObjectArrayMemoryLeakTest/native-calls-wrapper.d.ts
vendored
Normal file
4
apps/perf-tests/LargeObjectArrayMemoryLeakTest/native-calls-wrapper.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare module "app/native-calls-wrapper" {
|
||||
export function createNativeDate(): any;
|
||||
export function forceGarbageCollection(): void;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export function forceGarbageCollection(): void {
|
||||
__collect();
|
||||
}
|
||||
|
||||
export function createNativeDate(): any {
|
||||
return NSDate.date();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
{ "name" : "LargeObjectArrayMemoryLeakTest",
|
||||
"main" : "app.js" }
|
||||
Reference in New Issue
Block a user