Page 1 of 1

trace(object) is extremely slow?

Posted: 27 Jan 2024, 17:14
by SmartfoxEnjoyer
After some testing I found that my physics simulation was taking about 120ms each step, after removing the trace() methods, it went down to about 1ms :shock:

I had about 12 of them in the whole physics step from start to finish for debugging reasons. Also they were tracing things like array.size() or list.get(0).myParameter, etc.

If i use trace("start") as an example, just a primitive String it only takes 1ms or less, but trace(object) seems to take very long. Can you please confirm if this is true?

Thanks.

Re: trace(object) is extremely slow?

Posted: 27 Jan 2024, 17:52
by Lapo
Maybe it depends on the object itself.
When you pass an object the .toString() method of that obj is invoked. I suspect that's where most of the time is spent. The trace() method uses log4j to log data, which is not that expensive in terms of cpu time.

Cheers