Sponsored Content
Operating Systems Linux Red Hat lightweight function for measuring time ( better than clock_getime ) Post 302539893 by manustone on Tuesday 19th of July 2011 04:29:01 AM
Old 07-19-2011
Hi
after few research I didn't find a better function than clock_getime or a specific function for RedHat distro BUT I can tell you that in the 2.6 kernel there are new ID available for clock_getime.
If you use version 2.6.28 you can use a new clock type, CLOCK_MONOTONIC_RAW
If you use version 2.6.32 you can use a new clock type, CLOCK_REALTIME_COARSE and CLOCK_MONOTIC_COARSE.

Someone did some tests with it and they seem 5 times faster than the code used by CLOCK_MONOTONIC and CLOCK_REALTIME.

Best Regards
MNSTN
 

7 More Discussions You Might Find Interesting

1. Programming

Measuring System Call Time

Can anyone please help me in measuring the system call timings! How do I do it if I have to measure the timing of an operation, say getpid system call. What different functions can I use for that and what would be the difference using each of them? Thanx! (3 Replies)
Discussion started by: chacha
3 Replies

2. Programming

C time in milliseconds function.

I need a c function which return the time in: hour min sec and mil sec I am writing on unix os. (3 Replies)
Discussion started by: kamil
3 Replies

3. Shell Programming and Scripting

time function

Hi, I would like to display the exact time taken to complete running a particular tool or function or program to user I don't know the exact time functions in unix, please help me thanks in advance Example: $test.ksh output should be The... (10 Replies)
Discussion started by: hsekol
10 Replies

4. Programming

function time

Hello I have problem with function 'time' to test my program for file copying . How to run the function in my source code ? I try something like that: system("time"); < -- but this don't working (2 Replies)
Discussion started by: scotty_123
2 Replies

5. Shell Programming and Scripting

Nawk Time Function

Hi All, I am using solaris and nawk. Is there any time function in nawk which is simliar to the shell `date` function ? Can any experts show any examples? (4 Replies)
Discussion started by: Raynon
4 Replies

6. UNIX for Dummies Questions & Answers

time function

hello everybody! i want to post a question. So, I use the command 'time a.out' to time the duration of the program a.out. The return value of this function was: real 0m4.116s user 0m4.112s sys 0m0.016s What i want is! I try to find a way to get (NOT manually) the value of real time.... (2 Replies)
Discussion started by: nicos
2 Replies

7. Ubuntu

Measuring the correctness of ndelay() function.

I wrote this kernel module to test the correctness of ndelay() function. Kernel mdoule: #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/time.h> #include <linux/delay.h> static int __init initialize(void) { ktime_t start, end; s64... (1 Reply)
Discussion started by: BHASKAR JUPUDI
1 Replies
clock_settime(3RT)					    Realtime Library Functions						clock_settime(3RT)

NAME
clock_settime, clock_gettime, clock_getres - high-resolution clock operations SYNOPSIS
cc [ flag... ] file... -lrt [ library... ] #include <time.h> int clock_settime(clockid_t clock_id, const struct timespec *tp); int clock_gettime(clockid_t clock_id, struct timespec *tp); int clock_getres(clockid_t clock_id, struct timespec *res); DESCRIPTION
The clock_settime() function sets the specified clock, clock_id, to the value specified by tp. Time values that are between two consecutive non-negative integer multiples of the resolution of the specified clock are truncated down to the smaller multiple of the resolution. The clock_gettime() function returns the current value tp for the specified clock, clock_id. The resolution of any clock can be obtained by calling clock_getres(). Clock resolutions are system-dependent and cannot be set by a process. If the argument res is not NULL, the resolution of the specified clock is stored in the location pointed to by res. If res is NULL, the clock resolution is not returned. If the time argument of clock_settime() is not a multiple of res, then the value is truncated to a multiple of res. A clock may be systemwide (that is, visible to all processes) or per-process (measuring time that is meaningful only within a process). A clock_id of CLOCK_REALTIME is defined in <time.h>. This clock represents the realtime clock for the system. For this clock, the values returned by clock_gettime() and specified by clock_settime() represent the amount of time (in seconds and nanoseconds) since the Epoch. Additional clocks may also be supported. The interpretation of time values for these clocks is unspecified. A clock_id of CLOCK_HIGHRES represents the non-adjustable, high-resolution clock for the system. For this clock, the value returned by clock_gettime(3RT) represents the amount of time (in seconds and nanoseconds) since some arbitrary time in the past; it is not correlated in any way to the time of day, and thus is not subject to resetting or drifting by way of adjtime(2), ntp_adjtime(2), settimeofday(3C), or clock_settime(). The time source for this clock is the same as that for gethrtime(3C). Additional clocks may also be supported. The interpretation of time values for these clocks is unspecified. RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The clock_settime(), clock_gettime() and clock_getres() functions will fail if: EINVAL The clock_id argument does not specify a known clock. ENOSYS The functions clock_settime(), clock_gettime(), and clock_getres() are not supported by this implementation. The clock_settime() function will fail if: EINVAL The tp argument to clock_settime() is outside the range for the given clock ID; or the tp argument specified a nanosecond value less than zero or greater than or equal to 1000 million. The clock_settime() function may fail if: EPERM The requesting process does not have the appropriate privilege to set the specified clock. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-------------------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-------------------------------------+ |Interface Stability |Standard | +-----------------------------+-------------------------------------+ |MT-Level |clock_gettime() is Async-Signal-Safe | +-----------------------------+-------------------------------------+ SEE ALSO
time(2), ctime(3C), gethrtime(3C), time.h(3HEAD), timer_gettime(3RT), attributes(5), standards(5) SunOS 5.10 28 Jun 2002 clock_settime(3RT)
All times are GMT -4. The time now is 09:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy