%%s 4/5/191 %%d D 1.2 30-Jul-83 09:15:07 tools 2 1 %%c Removed trailing periods from quoted strings. Also changed calls to impath %%c to static declarations using STD_PATH. %%s 0/0/0 %%d D 1.1 27-Mar-82 15:03:51 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- timer.r 3932 asc 25-mar-82 09:42:04 v1.1 (sw-tools v1.1) #-h- main 2823 asc 25-mar-82 09:41:56 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- timer.r 3904 asc 30-jul-83 09:14:34 tools (lblh csam sventek) #-h- main 2790 asc 30-jul-83 09:12:33 tools (lblh csam sventek) %%E 2 DRIVER(main) integer getarg, type, loccom, j, junk, spawn, intime, argst, found, long, termsg(TERMSGSIZE), pwait, getwrd, length integer*2 start(7), stop(7), final(7) character proces(FILENAMESIZE), arg(ARGBUFSIZE), args(ARGBUFSIZE), %%D 2 spath(arith(3,*,FILENAMESIZE)), %%E 2 image(FILENAMESIZE), clower, descr(PIDSIZE) string sh "sh" string local "local" string suffix BOTH_SUFFIX string imgsuf IMAGE_SUFFIX string usestr "usage: timer [-v] 'command [arguments]'" %%I 2 string spath STD_PATH %%E 2 call query(usestr) found = NO long = NO for (j=1; getarg(j, args, ARGBUFSIZE) != EOF; j=j+1) if (args(1) == '-' & clower(args(2)) == 'v') long = YES else { found = YES call scopy(args, 1, arg, 1) } if (found == NO) call error(usestr) %%D 2 call impath(spath) %%E 2 i = 1 junk = getwrd(arg, i, proces) type = loccom(proces, spath, suffix, image) if (type == ASCII) { j = 1 call stcopy(sh, 1, args, j) call chcopy(' ', args, j) call stcopy(image, 1, args, j) call scopy(arg, i, args, j) if (loccom(sh, spath, imgsuf, image) != BINARY) %%D 2 call error("Cannot locate shell image.") %%E 2 %%I 2 call error("Cannot locate shell image") %%E 2 } else { call scopy(arg, 1, args, 1) if (type != BINARY) call scopy(local, 1, image, 1) } if (spawn(image, args, descr, NOWAIT) == ERR) { call putlin("Error in spawning ", ERROUT) call error(image) } junk = pwait(1, descr, termsg, descr, ANDWAIT) call timfmt("elapsed CPU time: ", termsg(12), args) call putlin(args, STDOUT) call putc('@n') call sys$numtim(start, termsg(19)) call sys$numtim(stop, termsg(5)) if (stop(7) < start(7)) { stop(7) = stop(7) + 100 stop(6) = stop(6) - 1 } final(7) = stop(7) - start(7) if (stop(6) < start(6)) { stop(6) = stop(6) + 60 stop(5) = stop(5) - 1 } final(6) = (stop(6) - start(6)) if (stop(5) < start(5)) { stop(5) = stop(5) + 60 stop(4) = stop(4) - 1 } final(5) = (stop(5) - start(5)) if (stop(4) < start(4)) { stop(4) = stop(4) + 24 stop(3) = stop(3) - 1 } final(4) = (stop(4) - start(4)) intime = final(4) intime = 60 * intime + final(5) intime = 60 * intime + final(6) intime = 100 * intime + final(7) call timfmt("elapsed clock time: ", intime, args) call putlin(args, STDOUT) call putc('@n') if (long == YES) { call putlin("page faults incurred: ", STDOUT) call putdec(termsg(13), 13) call putc('@n') call putlin("peak page file usage: ", STDOUT) call putdec(termsg(14), 13) call putc('@n') call putlin("peak working set size: ", STDOUT) call putdec(termsg(15), 13) call putc('@n') call putlin("buffered I/O count: ", STDOUT) call putdec(termsg(16), 13) call putc('@n') call putlin("direct I/O count: ", STDOUT) call putdec(termsg(17), 13) call putc('@n') } DRETURN end #-h- timfmt 963 asc 25-mar-82 09:41:58 v1.1 (sw-tools v1.1) subroutine timfmt(string, intime, buf) integer time(4), n, itoc, j, k, intime character buf(ARB), string(ARB), temp(5) time(3) = intime / 100 time(4) = intime - 100 * time(3) time(2) = time(3) / 60 time(3) = time(3) - 60 * time(2) time(1) = time(2) / 60 time(2) = time(2) - 60 * time(1) j = 1 call stcopy(string, 1, buf, j) n = 4 -itoc(time(1), temp, 5) for (k=1; k <= n; k=k+1) { buf(j) = ' ' j = j + 1 } call stcopy(temp, 1, buf, j) buf(j) = ':' j = j + 1 n = 2 - itoc(time(2), temp, 3) for (k=1; k <= n; k=k+1) { buf(j) = '0' j = j + 1 } call stcopy(temp, 1, buf, j) buf(j) = ':' j = j + 1 n = 2 - itoc(time(3), temp, 3) for (k=1; k <= n; k=k+1) { buf(j) = '0' j = j + 1 } call stcopy(temp, 1, buf, j) buf(j) = '.' j = j + 1 n = 2 - itoc(time(4), temp, 3) for (k=1; k <= n; k=k+1) { buf(j) = '0' j = j + 1 } call stcopy(temp, 1, buf, j) buf(j) = EOS return end #-h- timer.fmt 900 asc 25-mar-82 09:42:06 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Timer (1) 8-Jun-79 time execution of a process .sy timer [-v] "command [arguments]" .ds timer spawns a subprocess performing the requested command, and displays the CPU time and wall time which elapsed during the execution of the command on the standard output. The -v flag causes timer to display other system-dependent quantities concerning the subprocess performing the requested command. The command specified is searched for using the same search path as the shell. .fl none .sa The UNIX programmer's manual, time(I) .br sh - shell (command line interpreter) .di is an invalid image or script file name .in +5 The requested command could not be found in the searched directories. .in -5 Error in spawning .in +5 The requested image or script file was located, but the process to perform the command could not be spawned. .in -5 .au Joe Sventek(VAX) .bu %%E 1