Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > G

gethrtime(3C)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

gethrtime() — get high resolution time

SYNOPSIS

#include <time.h>

hrtime_t gethrtime(void);

DESCRIPTION

The gethrtime() function returns the current high-resolution real time. Time is expressed as nanoseconds since a certain time in the past. This API uses a fast light weight system call to get the nanoseconds from a certain time. It is not correlated in any way to the time of day. This API is used for performance measurement tasks and is used for cheap and accurate interval timing.

hrtime_t is a signed 64-bit number.

RETURN VALUE

Upon successful completion, gethrtime() returns a number of nanoseconds. Otherwise, a value of -1 is returned.

WARNINGS

This API will only be available if the application is being compiled in -Ae mode (extended ANSI) because 64-bit integer numbers are not available in -Aa (ANSI) mode. Please refer to cc(1).

EXAMPLES

The following code fragment measures the average cost of getgid():

hrtime_t begin, end; int i, count = 1000; begin = gethrtime(); for (i = 0; i < count; i++) getgid(); end = gethrtime(); printf("Avg getgid() time = %lld nsec", (end - begin)/count );

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.