Skip to main content

cpu_time

Function cpu_time 

Source
pub fn cpu_time() -> Number
Expand description

CPU time in seconds. Equivalent to Ipopt::CpuTime.

On Unix this returns the process’s accumulated user CPU time via getrusage(RUSAGE_SELF).ru_utime, exactly matching upstream Ipopt’s CpuTime() (src/Common/IpUtils.cpp). This is what max_cpu_time is meant to bound — a busy solve accrues CPU time at roughly the wall rate, but time spent blocked/sleeping does not count.

std exposes no portable CPU-time API, so non-Unix targets (Windows) fall back to wallclock. That mirrors upstream too: its Windows path uses clock(), which on the MSVC runtime measures elapsed real time rather than CPU time, so the two are already equivalent there.