Re: CPU Creating Objects vs Modifying Object Properties
- From: Thomas 'PointedEars' Lahn <PointedEars@xxxxxx>
- Date: Thu, 31 Jan 2008 22:14:25 +0100
dhtml wrote:
What is the best way to monitor CPU activity and performance?
THis is more of a testing question.
I have an option to do either:
1) mixedColor = new Color(r, g, b)
2) mixedColor.r = r, mixedColor.g = g, mixedColor.b = b
This may happen repeatedly in an animation.
My assumption is that (2) would be a lot more efficient. I just don't
have a good way or testing it. Ideally a native benchmarking tool
would monitor performance of the jseng in various browsers (or at
least 2)
Firebug has a built-in profiler, and you can also use this template to test
runtime efficiency:
if (typeof console == "undefined")
{
var console = {
log: function()
{
window.alert(Array.prototype.join.call(arguments, ""));
}
};
}
var start = new Date();
// n >= 10000
for (var i = n; i--;)
{
// test subject
}
console.log(new Date() - start, " ms");
Also, what about double threading for animations? Is it too much of a
CPU hog to start setInterval twice for one run() method?
Probably not. What is important is that the intervals do not get too short
and that they do not overlap for changing the same property. Which is why
window.setTimeout() should be used in favor of window.setInterval() in
animations.
PointedEars
.
- Follow-Ups:
- References:
- Prev by Date: Re: CPU Creating Objects vs Modifying Object Properties
- Next by Date: Re: CPU Creating Objects vs Modifying Object Properties
- Previous by thread: Re: CPU Creating Objects vs Modifying Object Properties
- Next by thread: Re: CPU Creating Objects vs Modifying Object Properties
- Index(es):
Relevant Pages
|