Export I_nsTime to ZScript.

Moderator: GZDoom Developers

Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Export I_nsTime to ZScript.

Post by Accensus »

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.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Export I_nsTime to ZScript.

Post by Marisa the Magician »

This would be desirable too. Some of us do try to roll out our own profiling methods, and MSTime isn't very helpful.
_mental_
 
 
Posts: 3816
Joined: Sun Aug 07, 2011 4:32 am

Re: Export I_nsTime to ZScript.

Post by _mental_ »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49142
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Export I_nsTime to ZScript.

Post by Graf Zahl »

We do have floats, though.
How many nanoseconds fit into 53 bits?
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Export I_nsTime to ZScript.

Post by Marisa the Magician »

I think that'd allow for up to 104 days before it wraps around (if I'm doing the math correctly).
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49142
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Export I_nsTime to ZScript.

Post by Graf Zahl »

It won't wrap around, though. It'll continue to count upwards but gradually lose precision.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Export I_nsTime to ZScript.

Post by Apeirogon »

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".
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Export I_nsTime to ZScript.

Post by Marisa the Magician »

I've opened a PR for this. As discussed I've made it return a double.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49142
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Export I_nsTime to ZScript.

Post by Graf Zahl »

Added MSTimeF instead

Return to “Closed Feature Suggestions [GZDoom]”