Export I_nsTime to ZScript.

Thu Jun 10, 2021 10:56 am

I'm trying to use MSTime to benchmark a piece of code because there are too many other actors that run at the same time to be able to rely on stat vm, as it fluctuates too much. Unfortunately, I don't think MSTime offers me the precision I'm looking for. Would it be possible to export I_nsTime to ZScript as NSTime?

EDIT: a temporary workaround that got suggested to me is to run the suspected code in a loop. Not the most elegant solution, but it works. Still, having more precise numbers would be rad.

Re: Export I_nsTime to ZScript.

Fri Jun 11, 2021 1:07 am

This would be desirable too. Some of us do try to roll out our own profiling methods, and MSTime isn't very helpful.

Re: Export I_nsTime to ZScript.

Fri Jun 11, 2021 1:37 am

As we don't have 64-bit integers in ZScript, nanosecond resolution is out of question. Microseconds seem more acceptable, but still the counter wraps in less than 72 minutes. For performance profiling, it doesn't really matter.
However, there will always be some "exceptional" people who will use it in gameplay logic. And they will complain aloud that their "brilliant" mod ideas failed just because of this limitation.

Re: Export I_nsTime to ZScript.

Fri Jun 11, 2021 1:48 am

We do have floats, though.
How many nanoseconds fit into 53 bits?

Re: Export I_nsTime to ZScript.

Fri Jun 11, 2021 2:53 am

I think that'd allow for up to 104 days before it wraps around (if I'm doing the math correctly).

Re: Export I_nsTime to ZScript.

Fri Jun 11, 2021 2:59 am

It won't wrap around, though. It'll continue to count upwards but gradually lose precision.

Re: Export I_nsTime to ZScript.

Mon Jul 05, 2021 2:13 pm

Shouldnt it just stops incrementing?
I mean CPU will not be able to represent correctly result of addition 1 and 3*10^300, because all small ranked digits of a number would be outside of a number "scope".