From eea5f896780e07f7ca76685061d01e7be5a7abaa Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Thu, 11 Sep 2014 18:26:26 +0200 Subject: erts, kernel: Add os:perf_counter function The perf_counter is a very very cheap and high resolution timer that can be used to timestamp system events. It does not have monoticity guarantees, but should on most OS's expose a monotonous time. A special instruction has been created for this counter to further speed up fetching it. OTP-12908 --- lib/kernel/doc/src/os.xml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/kernel/doc/src/os.xml') diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml index 682d4a2eac..165160a909 100644 --- a/lib/kernel/doc/src/os.xml +++ b/lib/kernel/doc/src/os.xml @@ -37,6 +37,7 @@ use these functions can be of help in enabling a program to run on most platforms.

+ @@ -209,6 +210,30 @@ format_utc_timestamp() -> and os:system_time/1.

+ + + Returns a performance counter + +

Returns the current performance counter value in perf_counter + time unit. + This is a highly optimized call that might not be traceable. +

+
+
+ + + Returns a performance counter +

Returns a performance counter that can be used as a very fast and + high resolution timestamp. This counter is read directly from the hardware or operating + system with the same guarantees. This means that two consecutive calls + to the function are not guaranteed to be monotonic, though it most likely will be. + The performance counter till be converted to the resolution passed as an argument.

+
1> T1 = os:perf_counter(1000),receive after 10000 -> ok end,T2 = os:perf_counter(1000).
+176525861
+2> T2 - T1.
+10004
+
+
Return the OS family and, in some cases, OS name of the current operating system -- cgit v1.2.3