Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

WIP: test for performance tuning of event invoke #1211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions dist/zone-evergreen-testing-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,8 @@ function patchEventTarget(_global, apis, patchOptions) {
var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
var PREPEND_EVENT_LISTENER = 'prependListener';
var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
var invokeTask = function (task, target, event) {
var invokeTask = function (task, target, event, mergeCallback) {
if (mergeCallback === void 0) { mergeCallback = false; }
// for better performance, check isRemoved which is set
// by removeEventListener
if (task.isRemoved) {
Expand All @@ -1690,7 +1691,12 @@ function patchEventTarget(_global, apis, patchOptions) {
task.originalDelegate = delegate;
}
// invoke static task.invoke
task.invoke(task, target, [event]);
if (mergeCallback) {
task.callback.call(target, event);
}
else {
task.invoke(task, target, [event]);
}
var options = task.options;
if (options && typeof options === 'object' && options.once) {
// if options.once is true, after invoke once remove listener here
Expand Down Expand Up @@ -1718,17 +1724,22 @@ function patchEventTarget(_global, apis, patchOptions) {
if (tasks.length === 1) {
invokeTask(tasks[0], target, event);
}
else {
else if (tasks.length > 1) {
// https://github.com/angular/zone.js/issues/836
// copy the tasks array before invoke, to avoid
// the callback will remove itself or other listener
var copyTasks = tasks.slice();
for (var i = 0; i < copyTasks.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
break;
var copyTasks_1 = tasks.slice();
var mergedCallback = function () {
for (var i = 0; i < copyTasks_1.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
return;
}
invokeTask(copyTasks_1[i], target, event, true);
}
invokeTask(copyTasks[i], target, event);
}
};
var mergedTask = Object.create(copyTasks_1[0]);
mergedTask.callback = mergedCallback;
invokeTask(mergedTask, target, event);
}
}
};
Expand Down
26 changes: 18 additions & 8 deletions dist/zone-evergreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ function patchEventTarget(_global, apis, patchOptions) {
const ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
const PREPEND_EVENT_LISTENER = 'prependListener';
const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
const invokeTask = function (task, target, event) {
const invokeTask = function (task, target, event, mergeCallback = false) {
// for better performance, check isRemoved which is set
// by removeEventListener
if (task.isRemoved) {
Expand All @@ -1600,7 +1600,12 @@ function patchEventTarget(_global, apis, patchOptions) {
task.originalDelegate = delegate;
}
// invoke static task.invoke
task.invoke(task, target, [event]);
if (mergeCallback) {
task.callback.call(target, event);
}
else {
task.invoke(task, target, [event]);
}
const options = task.options;
if (options && typeof options === 'object' && options.once) {
// if options.once is true, after invoke once remove listener here
Expand Down Expand Up @@ -1628,17 +1633,22 @@ function patchEventTarget(_global, apis, patchOptions) {
if (tasks.length === 1) {
invokeTask(tasks[0], target, event);
}
else {
else if (tasks.length > 1) {
// https://github.com/angular/zone.js/issues/836
// copy the tasks array before invoke, to avoid
// the callback will remove itself or other listener
const copyTasks = tasks.slice();
for (let i = 0; i < copyTasks.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
break;
const mergedCallback = function () {
for (let i = 0; i < copyTasks.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
return;
}
invokeTask(copyTasks[i], target, event, true);
}
invokeTask(copyTasks[i], target, event);
}
};
const mergedTask = Object.create(copyTasks[0]);
mergedTask.callback = mergedCallback;
invokeTask(mergedTask, target, event);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion dist/zone-evergreen.min.js

Large diffs are not rendered by default.

29 changes: 20 additions & 9 deletions dist/zone-mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,8 @@ function patchEventTarget(_global, apis, patchOptions) {
var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
var PREPEND_EVENT_LISTENER = 'prependListener';
var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
var invokeTask = function (task, target, event) {
var invokeTask = function (task, target, event, mergeCallback) {
if (mergeCallback === void 0) { mergeCallback = false; }
// for better performance, check isRemoved which is set
// by removeEventListener
if (task.isRemoved) {
Expand All @@ -1695,7 +1696,12 @@ function patchEventTarget(_global, apis, patchOptions) {
task.originalDelegate = delegate;
}
// invoke static task.invoke
task.invoke(task, target, [event]);
if (mergeCallback) {
task.callback.call(target, event);
}
else {
task.invoke(task, target, [event]);
}
var options = task.options;
if (options && typeof options === 'object' && options.once) {
// if options.once is true, after invoke once remove listener here
Expand Down Expand Up @@ -1723,17 +1729,22 @@ function patchEventTarget(_global, apis, patchOptions) {
if (tasks.length === 1) {
invokeTask(tasks[0], target, event);
}
else {
else if (tasks.length > 1) {
// https://github.com/angular/zone.js/issues/836
// copy the tasks array before invoke, to avoid
// the callback will remove itself or other listener
var copyTasks = tasks.slice();
for (var i = 0; i < copyTasks.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
break;
var copyTasks_1 = tasks.slice();
var mergedCallback = function () {
for (var i = 0; i < copyTasks_1.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
return;
}
invokeTask(copyTasks_1[i], target, event, true);
}
invokeTask(copyTasks[i], target, event);
}
};
var mergedTask = Object.create(copyTasks_1[0]);
mergedTask.callback = mergedCallback;
invokeTask(mergedTask, target, event);
}
}
};
Expand Down
29 changes: 20 additions & 9 deletions dist/zone-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,8 @@ function patchEventTarget(_global, apis, patchOptions) {
var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
var PREPEND_EVENT_LISTENER = 'prependListener';
var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
var invokeTask = function (task, target, event) {
var invokeTask = function (task, target, event, mergeCallback) {
if (mergeCallback === void 0) { mergeCallback = false; }
// for better performance, check isRemoved which is set
// by removeEventListener
if (task.isRemoved) {
Expand All @@ -1609,7 +1610,12 @@ function patchEventTarget(_global, apis, patchOptions) {
task.originalDelegate = delegate;
}
// invoke static task.invoke
task.invoke(task, target, [event]);
if (mergeCallback) {
task.callback.call(target, event);
}
else {
task.invoke(task, target, [event]);
}
var options = task.options;
if (options && typeof options === 'object' && options.once) {
// if options.once is true, after invoke once remove listener here
Expand Down Expand Up @@ -1637,17 +1643,22 @@ function patchEventTarget(_global, apis, patchOptions) {
if (tasks.length === 1) {
invokeTask(tasks[0], target, event);
}
else {
else if (tasks.length > 1) {
// https://github.com/angular/zone.js/issues/836
// copy the tasks array before invoke, to avoid
// the callback will remove itself or other listener
var copyTasks = tasks.slice();
for (var i = 0; i < copyTasks.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
break;
var copyTasks_1 = tasks.slice();
var mergedCallback = function () {
for (var i = 0; i < copyTasks_1.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
return;
}
invokeTask(copyTasks_1[i], target, event, true);
}
invokeTask(copyTasks[i], target, event);
}
};
var mergedTask = Object.create(copyTasks_1[0]);
mergedTask.callback = mergedCallback;
invokeTask(mergedTask, target, event);
}
}
};
Expand Down
29 changes: 20 additions & 9 deletions dist/zone-testing-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,8 @@ function patchEventTarget(_global, apis, patchOptions) {
var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
var PREPEND_EVENT_LISTENER = 'prependListener';
var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
var invokeTask = function (task, target, event) {
var invokeTask = function (task, target, event, mergeCallback) {
if (mergeCallback === void 0) { mergeCallback = false; }
// for better performance, check isRemoved which is set
// by removeEventListener
if (task.isRemoved) {
Expand All @@ -1690,7 +1691,12 @@ function patchEventTarget(_global, apis, patchOptions) {
task.originalDelegate = delegate;
}
// invoke static task.invoke
task.invoke(task, target, [event]);
if (mergeCallback) {
task.callback.call(target, event);
}
else {
task.invoke(task, target, [event]);
}
var options = task.options;
if (options && typeof options === 'object' && options.once) {
// if options.once is true, after invoke once remove listener here
Expand Down Expand Up @@ -1718,17 +1724,22 @@ function patchEventTarget(_global, apis, patchOptions) {
if (tasks.length === 1) {
invokeTask(tasks[0], target, event);
}
else {
else if (tasks.length > 1) {
// https://github.com/angular/zone.js/issues/836
// copy the tasks array before invoke, to avoid
// the callback will remove itself or other listener
var copyTasks = tasks.slice();
for (var i = 0; i < copyTasks.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
break;
var copyTasks_1 = tasks.slice();
var mergedCallback = function () {
for (var i = 0; i < copyTasks_1.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
return;
}
invokeTask(copyTasks_1[i], target, event, true);
}
invokeTask(copyTasks[i], target, event);
}
};
var mergedTask = Object.create(copyTasks_1[0]);
mergedTask.callback = mergedCallback;
invokeTask(mergedTask, target, event);
}
}
};
Expand Down
29 changes: 20 additions & 9 deletions dist/zone-testing-node-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,8 @@ function patchEventTarget(_global, apis, patchOptions) {
var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
var PREPEND_EVENT_LISTENER = 'prependListener';
var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
var invokeTask = function (task, target, event) {
var invokeTask = function (task, target, event, mergeCallback) {
if (mergeCallback === void 0) { mergeCallback = false; }
// for better performance, check isRemoved which is set
// by removeEventListener
if (task.isRemoved) {
Expand All @@ -1609,7 +1610,12 @@ function patchEventTarget(_global, apis, patchOptions) {
task.originalDelegate = delegate;
}
// invoke static task.invoke
task.invoke(task, target, [event]);
if (mergeCallback) {
task.callback.call(target, event);
}
else {
task.invoke(task, target, [event]);
}
var options = task.options;
if (options && typeof options === 'object' && options.once) {
// if options.once is true, after invoke once remove listener here
Expand Down Expand Up @@ -1637,17 +1643,22 @@ function patchEventTarget(_global, apis, patchOptions) {
if (tasks.length === 1) {
invokeTask(tasks[0], target, event);
}
else {
else if (tasks.length > 1) {
// https://github.com/angular/zone.js/issues/836
// copy the tasks array before invoke, to avoid
// the callback will remove itself or other listener
var copyTasks = tasks.slice();
for (var i = 0; i < copyTasks.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
break;
var copyTasks_1 = tasks.slice();
var mergedCallback = function () {
for (var i = 0; i < copyTasks_1.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
return;
}
invokeTask(copyTasks_1[i], target, event, true);
}
invokeTask(copyTasks[i], target, event);
}
};
var mergedTask = Object.create(copyTasks_1[0]);
mergedTask.callback = mergedCallback;
invokeTask(mergedTask, target, event);
}
}
};
Expand Down
29 changes: 20 additions & 9 deletions dist/zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,8 @@ function patchEventTarget(_global, apis, patchOptions) {
var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
var PREPEND_EVENT_LISTENER = 'prependListener';
var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
var invokeTask = function (task, target, event) {
var invokeTask = function (task, target, event, mergeCallback) {
if (mergeCallback === void 0) { mergeCallback = false; }
// for better performance, check isRemoved which is set
// by removeEventListener
if (task.isRemoved) {
Expand All @@ -1690,7 +1691,12 @@ function patchEventTarget(_global, apis, patchOptions) {
task.originalDelegate = delegate;
}
// invoke static task.invoke
task.invoke(task, target, [event]);
if (mergeCallback) {
task.callback.call(target, event);
}
else {
task.invoke(task, target, [event]);
}
var options = task.options;
if (options && typeof options === 'object' && options.once) {
// if options.once is true, after invoke once remove listener here
Expand Down Expand Up @@ -1718,17 +1724,22 @@ function patchEventTarget(_global, apis, patchOptions) {
if (tasks.length === 1) {
invokeTask(tasks[0], target, event);
}
else {
else if (tasks.length > 1) {
// https://github.com/angular/zone.js/issues/836
// copy the tasks array before invoke, to avoid
// the callback will remove itself or other listener
var copyTasks = tasks.slice();
for (var i = 0; i < copyTasks.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
break;
var copyTasks_1 = tasks.slice();
var mergedCallback = function () {
for (var i = 0; i < copyTasks_1.length; i++) {
if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
return;
}
invokeTask(copyTasks_1[i], target, event, true);
}
invokeTask(copyTasks[i], target, event);
}
};
var mergedTask = Object.create(copyTasks_1[0]);
mergedTask.callback = mergedCallback;
invokeTask(mergedTask, target, event);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion dist/zone.min.js

Large diffs are not rendered by default.

Loading