1*47944Sbostic /*- 2*47944Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*47944Sbostic * All rights reserved. 42406Sdlw * 5*47944Sbostic * %sccs.include.proprietary.c% 623008Skre */ 723008Skre 8*47944Sbostic #ifndef lint 9*47944Sbostic static char sccsid[] = "@(#)dtime_.c 5.2 (Berkeley) 04/12/91"; 10*47944Sbostic #endif /* not lint */ 11*47944Sbostic 1223008Skre /* 132406Sdlw * Returns the delta time since the last call to dtime. 142406Sdlw * 152406Sdlw * calling sequence: 162406Sdlw * real time(2) 172406Sdlw * call dtime(time) 182406Sdlw * where: 192406Sdlw * the 2 element array time will receive the user and system 202406Sdlw * elapsed time since the last call to dtime, or since the start 212406Sdlw * of execution. 222406Sdlw * 232406Sdlw * This routine can be called as function, and returns the sum of 242406Sdlw * user and system times. The time_array argument must always be given. 252406Sdlw * 262406Sdlw * The resolution for all timing is 1/60 second. 272406Sdlw */ 282406Sdlw 292406Sdlw #include <sys/types.h> 302406Sdlw #include <sys/times.h> 312406Sdlw 322406Sdlw struct tb { float usrtime; float systime; }; 332406Sdlw 342406Sdlw time_t dutime=0, dstime=0; 352406Sdlw 362406Sdlw float dtime_(dt)372406Sdlwdtime_(dt) struct tb *dt; 382406Sdlw { struct tms clock; 392406Sdlw 402406Sdlw times(&clock); 412406Sdlw dt->usrtime = (float)(clock.tms_utime - dutime) / 60.0; 422406Sdlw dt->systime = (float)(clock.tms_stime - dstime) / 60.0; 432406Sdlw dutime = clock.tms_utime; 442406Sdlw dstime = clock.tms_stime; 452406Sdlw return(dt->usrtime + dt->systime); 462406Sdlw } 47