CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Wed, 16 Jul 2025 21:16:47 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090210083352
location: https://web.archive.org/web/20090210083352/https://examples.oreilly.com/upt2/split/runtime
server-timing: captures_list;dur=0.781004, exclusion.robots;dur=0.061895, exclusion.robots.policy;dur=0.047425, esindex;dur=0.012627, cdx.remote;dur=109.103080, LoadShardBlock;dur=562.311923, PetaboxLoader3.datanode;dur=226.415801
x-app-server: wwwb-app200
x-ts: 302
x-tr: 703
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
set-cookie: SERVER=wwwb-app200; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Wed, 16 Jul 2025 21:16:48 GMT
content-type: text/plain
content-length: 3103
x-archive-orig-date: Tue, 10 Feb 2009 08:33:52 GMT
x-archive-orig-server: Apache
x-archive-orig-last-modified: Mon, 31 Mar 2008 18:10:12 GMT
x-archive-orig-etag: "b0a866-c1f-90194900"
x-archive-orig-accept-ranges: bytes
x-archive-orig-content-length: 3103
x-archive-orig-connection: close
cache-control: max-age=1800
x-archive-guessed-content-type: text/plain
x-archive-guessed-charset: utf-8
memento-datetime: Tue, 10 Feb 2009 08:33:52 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 19 Aug 2002 08:59:27 GMT", ; rel="prev memento"; datetime="Sun, 18 May 2008 20:47:08 GMT", ; rel="memento"; datetime="Tue, 10 Feb 2009 08:33:52 GMT", ; rel="next memento"; datetime="Wed, 30 Sep 2015 16:45:28 GMT", ; rel="last memento"; datetime="Fri, 25 Mar 2016 03:27:12 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_8_20090210075601_crawl103-c/52_8_20090210083255_crawl100.arc.gz
server-timing: captures_list;dur=0.565853, exclusion.robots;dur=0.023491, exclusion.robots.policy;dur=0.014188, esindex;dur=0.011619, cdx.remote;dur=74.092620, LoadShardBlock;dur=172.083450, PetaboxLoader3.datanode;dur=287.303135, load_resource;dur=209.667864, PetaboxLoader3.resolve;dur=79.518231
x-app-server: wwwb-app200
x-ts: 200
x-tr: 488
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
accept-ranges: bytes
#! /bin/csh -f
#
### runtime - run program repetitively and output time-usage statistics
### Usage: runtime -n program_name [options_and_arguments] &
##
## runtime RUNS A PROGRAM, OVER AND OVER AGAIN, COLLECTING
## DATA ABOUT THE TIME IT TAKES TO RUN. runtime OUTPUTS
## A LIST OF THE INDIVIDUAL (C-SHELL) time RESULTS FOR EACH
## PROGRAM EXECUTION, PLUS A TOTAL AND AVERAGE.
##
## THE -n OPTION IS REQUIRED; IT'S THE NUMBER OF TIMES TO RUN THE
## program_name. FOR EXAMPLE,
## % runtime -25 testprog
## WILL RUN testprog 25 TIMES.
##
## IF THE STRING TO EXECUTE HAS ANY SPECIAL CHARACTERS THAT THE SHELL
## SHOULDN'T INTERPRET UNTIL EXECUTION, QUOTE THE STRING OR USE BACKSLASHES.
## NOTE THAT THE QUOTED STRING CAN'T HAVE ANY REDIRECTION IN IT; THAT'S
## BECAUSE runtime DOES SOME REDIRECTION OF ITS OWN.
set temp=/tmp/$$RUNTIME
set stat=1 # EXIT STATUS ON ERROR (SET TO 0 BEFORE NORMAL EXIT)
onintr cleanup
set count=`expr "$1" : '-\([0-9]*\)'` # REMOVE LEADING DASH
# TEST FOR CORRECT SYNTAX OF $1 AND CORRECT NUMBER OF ARGUMENTS:
if ( ("$count" !~ [0-9]*) || ($#argv < 2) ) then
echo "Usage: `basename $0` -number_of_times command_line_to_run"
exit 1
endif
# BUILD TEST FILE (/tmp/$$RUNTIME1):
echo set time >! ${temp}1
repeat $count echo "$argv[2-] >& /dev/null" >> ${temp}1
# RUN TEST FILE AND STORE RESULTS IN /tmp/$$RUNTIME2:
set starttime=`date`
/bin/csh -f < ${temp}1 >& ${temp}2
set endtime=`date`
# CHOP FIELDS FROM /tmp/$$RUNTIME2 AND PUT INTO /tmp/$$RUNTIME3;
# sed DOES CHOPPING AND tr CHANGES COLON IN FIELD 3 TO A SPACE.
# (TYPICAL LINE IN FILE 2: "0.5u 1.7s 0:04 53% 12+7k 13+17io 20pf+0w")
# (TYPICAL LINE IN FILE 3: "0.5 1.7 0 04 12 7 13 17 20 0")
sed -e 's/\(.*\..\)u \(.*\..\)s \(.*:.*\) .*% \(.*\)+\(.*\)k \(.*\)+\(.*\)io \(.*\)pf+\(.*\)w/\1 \2 \3 \4 \5 \6 \7 \8 \9/' \
-e 's/:/ /g' ${temp}2 > ${temp}3
# PRINT HEADER AND INDIVIDUAL RESULTS:
cat << ENDOFTHIS
runtime summary -- $count runs of
% $argv[2-]
(working directory = $cwd)
First run started at: $starttime
Last run finished at: $endtime
-----------------------------------------------
RUN # ***INDIVIDUAL RESULTS***
`cat -n ${temp}2`
ENDOFTHIS
# PRINT AVERAGES (AND A BLANK LINE AFTER THEM):
awk '{ \
field[1] += $1 \
field[2] += $2 \
# CONVERT SECONDS ($4) TO DECIMAL MINUTES, THEN ADD TO MINUTES ($3):\
field[3] += ($3 + $4/60) \
# ADD $5 TO field[4], $6 TO field[5], etc... \
for (i = 5; i <= 10; i++) \
field[i - 1] += $i \
} \
END { \
print "AVERAGES:" \
printf "%5.2fu ", field[1]/NR \
printf "%5.2fs ", field[2]/NR \
temp = int(field[3]/NR) \
printf "%d:%02d ", temp, (field[3]/NR - temp) * 60 \
printf "%d+%dk ", field[4]/NR, field[5]/NR \
printf "%d+%dio ", field[6]/NR, field[7]/NR \
printf "%dpf+%dw ", field[8]/NR, field[9]/NR \
printf "\n\n" \
}' ${temp}3
set stat=0 # IF GET HERE, WE'RE ABOUT DONE; SET STATUS FOR NORMAL EXIT
cleanup:
rm -f "$temp"{1,2,3}
exit $stat