@qooxdoo/framework
Version:
The JS Framework for Coders
79 lines (73 loc) • 1.89 kB
JavaScript
qx.Class.define("qx.test.performance.Property",
{
extend : qx.dev.unit.TestCase,
include : qx.dev.unit.MMeasure,
members :
{
SET_ITERATIONS : 10000,
testPropertySet : function()
{
var Clazz = qx.Class.define("demo.MyClass", {
extend: qx.core.Object,
properties: {
alpha: {
init: null,
nullable: true,
check: "String",
event: "changeAlpha"
}
}
});
var obj = new Clazz();
obj.addListener("changeAlpha", function() {}, this);
var self = this;
this.measure(
"property set",
function() {
for (var i=0; i<self.SET_ITERATIONS; i++) {
obj.setAlpha("value #" + i);
}
},
function() {
obj.dispose();
qx.Class.undefine("demo.MyClass");
},
this.SET_ITERATIONS
);
},
testAsyncPropertySet : function()
{
if (qx.core.Environment.get("qx.promise.longStackTraces")) {
(console.log||this.warn)("Long Stack Traces are enabled - this will significantly slow down the test");
}
var Clazz = qx.Class.define("demo.MyClass", {
extend: qx.core.Object,
properties: {
alpha: {
init: null,
nullable: true,
check: "String",
event: "changeAlpha",
async: true
}
}
});
var obj = new Clazz();
obj.addListener("changeAlpha", function() {}, this);
var self = this;
this.measure(
"property set",
function() {
for (var i=0; i<self.SET_ITERATIONS; i++) {
obj.setAlpha("value #" + i);
}
},
function() {
obj.dispose();
qx.Class.undefine("demo.MyClass");
},
this.SET_ITERATIONS
);
}
}
});