xref: /original-bsd/usr.bin/f77/libU77/dtime_.c (revision a7108741)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)dtime_.c	5.2 (Berkeley) 04/12/91";
10 #endif /* not lint */
11 
12 /*
13  * Returns the delta time since the last call to dtime.
14  *
15  * calling sequence:
16  * 	real time(2)
17  * 	call dtime(time)
18  * where:
19  * 	the 2 element array time will receive the user and system
20  * 	elapsed time since the last call to dtime, or since the start
21  * 	of execution.
22  *
23  * This routine can be called as function, and returns the sum of
24  * user and system times. The time_array argument must always be given.
25  *
26  * The resolution for all timing is 1/60 second.
27  */
28 
29 #include <sys/types.h>
30 #include <sys/times.h>
31 
32 struct tb { float usrtime; float systime; };
33 
34 time_t dutime=0, dstime=0;
35 
36 float
37 dtime_(dt) struct tb *dt;
38 {	struct tms clock;
39 
40 	times(&clock);
41 	dt->usrtime = (float)(clock.tms_utime - dutime) / 60.0;
42 	dt->systime = (float)(clock.tms_stime - dstime) / 60.0;
43 	dutime = clock.tms_utime;
44 	dstime = clock.tms_stime;
45 	return(dt->usrtime + dt->systime);
46 }
47