MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_process_time

Function get_process_time

crates/vm/src/stdlib/time.rs:820–833  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

818
819 #[cfg(all(target_arch = "wasm32", target_os = "emscripten"))]
820 fn get_process_time(vm: &VirtualMachine) -> PyResult<Duration> {
821 let t: libc::tms = unsafe {
822 let mut t = core::mem::MaybeUninit::uninit();
823 if libc::times(t.as_mut_ptr()) == -1 {
824 return Err(vm.new_os_error("Failed to get clock time".to_owned()));
825 }
826 t.assume_init()
827 };
828 let freq = unsafe { libc::sysconf(libc::_SC_CLK_TCK) };
829
830 Ok(Duration::from_nanos(
831 time_muldiv(t.tms_utime, SEC_TO_NS, freq) + time_muldiv(t.tms_stime, SEC_TO_NS, freq),
832 ))
833 }
834
835 #[cfg(not(any(
836 windows,

Callers 2

process_timeFunction · 0.85
process_time_nsFunction · 0.85

Calls 13

timesFunction · 0.85
sysconfFunction · 0.85
time_muldivFunction · 0.85
get_clock_timeFunction · 0.85
getrusageFunction · 0.85
from_timevalFunction · 0.85
GetCurrentProcessFunction · 0.85
u64_from_filetimeFunction · 0.85
as_mut_ptrMethod · 0.80
new_os_errorMethod · 0.80
ErrClass · 0.50
to_ownedMethod · 0.45

Tested by

no test coverage detected