Skip to content

Commit

Permalink
remove startMeasure/stopMeasure calls for keyed frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
krausest committed Feb 4, 2020
1 parent 18d4d4c commit 89b546f
Show file tree
Hide file tree
Showing 40 changed files with 27 additions and 1,135 deletions.
33 changes: 1 addition & 32 deletions frameworks/keyed/angular-ivy/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,6 @@ interface Data {
label: string;
}

// Debugging performance not supported yet
let startTime: number;
let lastMeasure: string;
let startMeasure = function (name: string) {
startTime = performance.now();
lastMeasure = name;
};
let stopMeasure = function () {
var last = lastMeasure;
if (lastMeasure) {
window.setTimeout(function () {
lastMeasure = null;
var stop = performance.now();
var duration = 0;
console.log(last + ' took ' + (stop - startTime));
}, 0);
}
};

@Component({
selector: 'my-app',
template: `
Expand Down Expand Up @@ -88,7 +69,7 @@ let stopMeasure = function () {
</div>
`
})
export class AppComponent implements AfterViewChecked {
export class AppComponent {
data: Array<Data> = [];
selected: number = undefined;
id: number = 1;
Expand Down Expand Up @@ -122,15 +103,13 @@ export class AppComponent implements AfterViewChecked {
}

select(item: Data, event: Event) {
startMeasure('select');
event.preventDefault();
this.selected = item.id;
detectChanges(this);
}

delete(item: Data, event: Event) {
event.preventDefault();
startMeasure('delete');
for (let i = 0, l = this.data.length; i < l; i++) {
if (this.data[i].id === item.id) {
this.data.splice(i, 1);
Expand All @@ -141,52 +120,42 @@ export class AppComponent implements AfterViewChecked {
}

run() {
startMeasure('run');
this.data = this.buildData();
detectChanges(this);
}

add() {
startMeasure('add');
this.data = this.data.concat(this.buildData(1000));
detectChanges(this);
}

update() {
startMeasure('update');
for (let i = 0; i < this.data.length; i += 10) {
this.data[i].label += ' !!!';
}
detectChanges(this);
}

runLots() {
startMeasure('runLots');
this.data = this.buildData(10000);
this.selected = undefined;
detectChanges(this);
}

clear() {
startMeasure('clear');
this.data = [];
this.selected = undefined;
detectChanges(this);
}

swapRows() {
startMeasure('swapRows');
if (this.data.length > 998) {
var a = this.data[1];
this.data[1] = this.data[998];
this.data[998] = a;
}
detectChanges(this);
}

ngAfterViewChecked() {
stopMeasure();
}
}

// TODO: The properties would currently be dropped by closure compiler, figure it out
Expand Down
33 changes: 1 addition & 32 deletions frameworks/keyed/angular-ng/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,12 @@ interface Data {
label: string;
}

let startTime: number;
let lastMeasure: string;
let startMeasure = function (name: string) {
startTime = performance.now();
lastMeasure = name;
}
let stopMeasure = function () {
var last = lastMeasure;
if (lastMeasure) {
window.setTimeout(function () {
lastMeasure = null;
var stop = performance.now();
var duration = 0;
console.log(last + " took " + (stop - startTime));
}, 0);
}
}

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styles: []
})
export class AppComponent implements AfterViewChecked {
export class AppComponent {
data: Array<Data> = [];
selected: number = undefined;
id: number = 1;
Expand Down Expand Up @@ -60,14 +42,12 @@ export class AppComponent implements AfterViewChecked {
}

select(item: Data, event: Event) {
startMeasure("select");
event.preventDefault();
this.selected = item.id;
}

delete(item: Data, event: Event) {
event.preventDefault();
startMeasure("delete");
for (let i = 0, l = this.data.length; i < l; i++) {
if (this.data[i].id === item.id) {
this.data.splice(i, 1);
Expand All @@ -77,44 +57,33 @@ export class AppComponent implements AfterViewChecked {
}

run() {
startMeasure("run");
this.data = this.buildData();
}

add() {
startMeasure("add");
this.data = this.data.concat(this.buildData(1000));
}

update() {
startMeasure("update");
for (let i = 0; i < this.data.length; i += 10) {
this.data[i].label += ' !!!';
}
}
runLots() {
startMeasure("runLots");
this.data = this.buildData(10000);
this.selected = undefined;
}
clear() {
startMeasure("clear");
this.data = [];
this.selected = undefined;
}
swapRows() {
startMeasure("swapRows");
if (this.data.length > 998) {
var a = this.data[1];
this.data[1] = this.data[998];
this.data[998] = a;
}
}

ngAfterViewChecked() {
stopMeasure();
// console.log("hello");
}
}
/*
console.log instead of stopMeasure:
Expand Down
32 changes: 1 addition & 31 deletions frameworks/keyed/angular-noopzone/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@ interface Data {
label: string;
}

let startTime: number;
let lastMeasure: string;
let startMeasure = function (name: string) {
startTime = performance.now();
lastMeasure = name;
};
let stopMeasure = function () {
var last = lastMeasure;
if (lastMeasure) {
window.setTimeout(function () {
lastMeasure = null;
var stop = performance.now();
var duration = 0;
console.log(last + ' took ' + (stop - startTime));
}, 0);
}
};

@Component({
selector: 'my-app',
template: `
Expand Down Expand Up @@ -82,7 +64,7 @@ let stopMeasure = function () {
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
</div>`
})
export class AppComponent implements AfterViewChecked {
export class AppComponent {
data: Array<Data> = [];
selected: number = undefined;
id: number = 1;
Expand Down Expand Up @@ -116,15 +98,13 @@ export class AppComponent implements AfterViewChecked {
}

select(item: Data, event: Event) {
startMeasure('select');
event.preventDefault();
this.selected = item.id;
this.appRef.tick();
}

delete(item: Data, event: Event) {
event.preventDefault();
startMeasure('delete');
for (let i = 0, l = this.data.length; i < l; i++) {
if (this.data[i].id === item.id) {
this.data.splice(i, 1);
Expand All @@ -135,52 +115,42 @@ export class AppComponent implements AfterViewChecked {
}

run() {
startMeasure('run');
this.data = this.buildData();
this.appRef.tick();
}

add() {
startMeasure('add');
this.data = this.data.concat(this.buildData(1000));
this.appRef.tick();
}

update() {
startMeasure('update');
for (let i = 0; i < this.data.length; i += 10) {
this.data[i].label += ' !!!';
}
this.appRef.tick();
}

runLots() {
startMeasure('runLots');
this.data = this.buildData(10000);
this.selected = undefined;
this.appRef.tick();
}

clear() {
startMeasure('clear');
this.data = [];
this.selected = undefined;
this.appRef.tick();
}

swapRows() {
startMeasure('swapRows');
if (this.data.length > 998) {
var a = this.data[1];
this.data[1] = this.data[998];
this.data[998] = a;
}
this.appRef.tick();
}

ngAfterViewChecked() {
stopMeasure();
}
}

@NgModule({
Expand Down
Loading

0 comments on commit 89b546f

Please sign in to comment.