The following excerpt is from a Pro*C program that times
opening of a Oracle db.
============================================================================
#include <sys/types.h>
#include <sys/times.h>
struct tms before, after;
times(&before);
EXEC SQL CONNECT :uid USING :database;
times(&after);
printf(" user time: %ld seconds\n", after.tms_utime - before.tms_utime);
printf(" system time: %ld seconds\n", after.tms_stime - before.tms_stime);
=================================================================================
Results:
=================================================================================
ribm00 % time_open_and_selects
user time: 9 seconds
system time: 2 seconds
=================================================================================
The tms structure is defined in /usr/include/sys/times.h as:
struct tms {
clock_t tms_utime; /* user time */
clock_t tms_stime; /* system time */
clock_t tms_cutime; /* user time, children */
clock_t tms_cstime; /* system time, children */
extern clock_t times(struct tms *);
=================================================================================
Reference:
David Curry,"Telling Time and Timing Things",IN: "Using C on the UNIX System" ,p73-79
O'Reilley & Associates, Inc.,Feb 1991.
Betty McBreen E-MAIL mcbreen@bnl.gov PHONE 516-344-5111 FAX 516-344-1334
This archive was generated by hypermail 2b29 : Tue Feb 01 2000 - 20:35:19 EST