1*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 3*7c478bd9Sstevel@tonic-gate 4*7c478bd9Sstevel@tonic-gate 5*7c478bd9Sstevel@tonic-gate /* 6*7c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 7*7c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 8*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 9*7c478bd9Sstevel@tonic-gate */ 10*7c478bd9Sstevel@tonic-gate 11*7c478bd9Sstevel@tonic-gate /* 12*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13*7c478bd9Sstevel@tonic-gate * All Rights Reserved. 14*7c478bd9Sstevel@tonic-gate */ 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 17*7c478bd9Sstevel@tonic-gate 18*7c478bd9Sstevel@tonic-gate /* time programs */ 19*7c478bd9Sstevel@tonic-gate # include "stdio.h" 20*7c478bd9Sstevel@tonic-gate # include "sys/types.h" 21*7c478bd9Sstevel@tonic-gate 22*7c478bd9Sstevel@tonic-gate struct tbuffer { 23*7c478bd9Sstevel@tonic-gate long proc_user_time; 24*7c478bd9Sstevel@tonic-gate long proc_system_time; 25*7c478bd9Sstevel@tonic-gate long child_user_time; 26*7c478bd9Sstevel@tonic-gate long child_system_time; 27*7c478bd9Sstevel@tonic-gate }; 28*7c478bd9Sstevel@tonic-gate static long start, user, systm; 29*7c478bd9Sstevel@tonic-gate tick() 30*7c478bd9Sstevel@tonic-gate { 31*7c478bd9Sstevel@tonic-gate struct tbuffer tx; 32*7c478bd9Sstevel@tonic-gate time_t tp; 33*7c478bd9Sstevel@tonic-gate times (&tx); 34*7c478bd9Sstevel@tonic-gate time (&tp); 35*7c478bd9Sstevel@tonic-gate user = tx.proc_user_time; 36*7c478bd9Sstevel@tonic-gate systm= tx.proc_system_time; 37*7c478bd9Sstevel@tonic-gate start = tp; 38*7c478bd9Sstevel@tonic-gate } 39*7c478bd9Sstevel@tonic-gate tock() 40*7c478bd9Sstevel@tonic-gate { 41*7c478bd9Sstevel@tonic-gate struct tbuffer tx; 42*7c478bd9Sstevel@tonic-gate time_t tp; 43*7c478bd9Sstevel@tonic-gate float lap, use, sys; 44*7c478bd9Sstevel@tonic-gate if (start==0) return; 45*7c478bd9Sstevel@tonic-gate times (&tx); 46*7c478bd9Sstevel@tonic-gate time (&tp); 47*7c478bd9Sstevel@tonic-gate lap = (tp - start)/60.; 48*7c478bd9Sstevel@tonic-gate use = (tx.proc_user_time - user)/60.; 49*7c478bd9Sstevel@tonic-gate sys = (tx.proc_system_time - systm)/60.; 50*7c478bd9Sstevel@tonic-gate printf("Elapsed %.2f CPU %.2f (user %.2f, sys %.2f)\n", 51*7c478bd9Sstevel@tonic-gate lap, use+sys, use, sys); 52*7c478bd9Sstevel@tonic-gate } 53