Skip to content

Commit

Permalink
Sys: Clarify cpuTime documentation (#11834)
Browse files Browse the repository at this point in the history
The existing documentation can be confusing. I think its easy to assume that this returns the time since the process was started, especially if you dont understand how the native api's calculate it. It easy to mistake that this simply might be the wall time since the cpu was running and end up with unreliable behavior when sleep is introduced to your thread.

The new documentation makes this pretty clear I think.
  • Loading branch information
dimensionscape authored Nov 22, 2024
1 parent 88166dd commit a25a3c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions std/Sys.hx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ extern class Sys {
static function time():Float;

/**
Gives the most precise timestamp value available (in seconds),
but only accounts for the actual time spent running on the CPU for the current thread/process.
Returns CPU time consumed by the current process or thread, measured in seconds.
This value only includes the actual time the CPU has actively spent executing
instructions for the process/thread and excludes idle or sleep time. The precision
and behavior may vary depending on the platform and underlying implementation.
**/
static function cpuTime():Float;

Expand Down

0 comments on commit a25a3c6

Please sign in to comment.