[SCRIPTING] Add Runtime.GetCurrentTimeStamp() method
Hi,
Having access to Stopwatch would allow scripts to have more accurate internal diagnostics, by being able to measure actual script execution time and potentially act on it to optimize script performance.
The DateTime currently accessible is woefully inaccurate at high frequencies and totally incapable of measuring anything below a millisecond.
Exposing the sufficient timing without actually exposing the Stopwatch itself would be reasonably simple, as it is already done to some extent.
1) Expand Sandbox.Game.Entities.Blocks.MyProgrammableBlock.RuntimeInfo with:
public double GetCurrentTimeStamp() {
return (Stopwatch.GetTimestamp() - this.m_startTicks) * MyProgrammableBlock.RuntimeInfo.STOPWATCH_MS_FREQUENCY;
}
2) Expand IMyGridProgramRuntimeInfo to expose said method as well
3) Profit
Thank you for considering this.
Replies have been locked on this page!