#!/bin/sh # # @(#)$Id: benchmark 4835 2003-05-19 21:08:57Z pklausner $ GNU (c) Peter Klausner 2002 # # NAME: # benchmark - time a few typical Foswiki pages # # SYNOPSYS: # /your/twiki/url/path/benchmark # # DESCRIPTION: # 'benchmark' returns a plain text page with system information plus benchmark values. # The values are calculated like this: # Unix timex(1) measures TWiki's geturl script; it return real, user and system time. # real - (user + sys) = upper boundary for the time spent by TWiki, # if probing localhost # To get more reliable values, re-run each bench a few times. # To test different characteristics, measure these pages: # # TWiki/BumpyWord # Almost empty; it just renders all headers + footers # TWiki/ProjectContributor # A short page, but it involves searching all pages # TWiki/WebIndex # Medium size page, involves lots of RCS # TWiki/CompleteDocumentation # Large page, with lots of includes # benchmark -h # Calls a "hello world" perl script, which loads and compiles # all TWiki code and plug-ins, but does nothing else # # INSTALLATION # Drop into /your/foswiki/bin; make executable by webserver # Edit customization section. # # SEE ALSO: # Foswiki:Extensions/CacheAddOn # # customize here... baseurl=/twiki # path relative to twiki host, not full URL viewurl=$baseurl/view tries=10 # more tries, better statistic, more time delay=0 # delay retries to "find" different system load situations host=localhost port=80 geturl=./geturl perl=perl debug=0 # functions... bench() { i=$tries while [ $i -gt 0 ] do timex $geturl $host $2 $port >/dev/null sleep $delay i=`expr $i - 1` done 2>&1 | awk ' BEGIN {min = 999999; max = -min; OFS=" "} /^real/ {real = $2} /^user/ {user = $2} /^sys/ { delta= real - user - $2; ++cnt sum += delta if (delta < min) min = delta if (delta > max) max = delta if ('$debug'>0) print real, user, $2, "=" delta } END { printf("| %25s | %6.2f| %6.2f| %6.2f| %s |\n", \ "'"$1"'", min, sum / cnt, max, "'"$2"'") } ' } # Redirect output, flush header before stderr gets in the way echo "Content-type: text/plain " exec 2>&1 # parse options... v=echo while getopts b:dhqstv:x opt do case "$opt" in b) baseurl="$OPTARG";; d) debug=1;; h) $perl -wTe " use CGI::Carp qw( fatalsToBrowser ); use CGI; use lib ( '.' ); use lib ( '../lib' ); use TWiki; use strict; print 'hello world from ' . \$TWiki::defaultUrlHost; " exit 0;; s) $perl -wTe " use lib ( '.' ); use lib ( '../lib' ); do 'TWiki.cfg'; print 'hello world from ' . \$defaultUrlHost; " exit 0;; q) v=:;; v) viewurl="$OPTARG";; x) set -x;; *) exit;; esac done shift `expr $OPTIND - 1` $v "TWiki benchmark for `uname -n` ================================== Unix ---- `uname -a` Perl ---- `$perl -V` Webserver --------- `./geturl $host / $port | awk '{print} /^[ ]*$/{exit}'` Benchmarks ========== | Test case | Min[s]| Avg[s]| Max[s]| URL path |" if [ $# -lt 2 ] then bench "Start perl +req vars" $baseurl/benchmark?-s bench "Hello-world +load twiki" $baseurl/benchmark?-h bench "Short page" $viewurl/TWiki/BumpyWord bench "Formatted search" $viewurl/TWiki/ProjectContributor bench "Large index w/much RCS" $viewurl/TWiki/WebIndex bench "Large page w/INCLUDEs" $viewurl/TWiki/CompleteDocumentation else bench "$1" "$2" fi