Time measurement
cpuTime
CPU time in seconds
Implementation varies by platform:
- Windows/MinGW: Uses
clock()withCLOCKS_PER_SEC - Unix/Linux/macOS: Uses
getrusage(RUSAGE_SELF)for precise user time
Usage
Memory measurement
memUsed
Current memory usage in MB, or 0 if unsupported on this architecture
This function returns 0 on architectures where memory measurement is not implemented.
memUsedPeak
If true, returns only the historical peak. If false, returns the maximum of current and peak usage.
Peak memory usage in MB, or 0 if unsupported on this architecture
Usage
Resource limits
limitMemory
Maximum memory limit in megabytes
The exact semantics of memory limiting vary by architecture and operating system. On some systems, this may set a soft limit that can be exceeded temporarily.
Usage
limitTime
Maximum CPU time in seconds
The exact semantics vary by architecture. On Unix systems, this typically uses
setrlimit(RLIMIT_CPU, ...) which sends SIGXCPU when exceeded.Usage
Signal handling
sigTerm
Signal handler function that takes the signal number as parameter
Usage
The signals handled may vary by platform. Typically includes:
SIGINT(Ctrl+C)SIGTERM(termination request)SIGXCPU(CPU time limit exceeded)
FPU precision control
setX86FPUPrecision
This function is primarily relevant for x86 architectures where the FPU may use extended precision (80-bit) internally. It sets the FPU control word to use 64-bit (double) precision.
Usage
On Linux, this function uses
_FPU_SETCW() from <fpu_control.h>. On other platforms, it may be a no-op if FPU control is not available or necessary.Complete example
Platform compatibility
Fully supported on Windows (MSVC, MinGW) and Unix-like systems (Linux, macOS, BSD)
Returns 0 on unsupported architectures. Check implementation for your specific platform.
Uses
setrlimit() on Unix systems. Semantics vary by OS.Available signals depend on the operating system
Only active on x86 Linux with
fpu_control.h. No-op on other platforms.