#version 0.1 /* * bench.dsm - Benchmark module for DarkStar/EPIC4 * Author: Brian Weiss * Last modified: 2002/10/09 * * Copyright (c) 2002 Brian Weiss * Copyright (c) 2002 Ben Winslow * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. All redistributions, whether of source code or in binary form must * retain the above copyright notice, the above paragraph (the one * permitting redistribution), this list of conditions, and the following * disclaimer. * 2. The names of the author(s) may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS `AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ queue cleanup.bench { unless (isloaded(tools)) { ^alias -bench } ^alias -tabkey.cmd.bench } /* * This is a hacked up version of Ben's /BENCH, * ain't it great? ;-) */ alias bench (iter, cmd) { if (!cmd) { xecho -b Usage: /BENCH return } @ :start = utime() repeat $iter $cmd @ :end = utime() @ :first = [$word(0 $end).$pad(-6 0 $word(1 $end))] @ :second = [$word(0 $start).$pad(-6 0 $word(1 $start))] stack push set floating_point_math ^set floating_point_math on @ :answer = first - second @ :answer = tr(# #.#$trunc(6 $answer)) stack pop set floating_point_math if (functioncall()) { return $answer }{ xecho -b -l crap -- $iter iterations of \"$cmd\": $answer\s } } alias startbench (iter, void) { @ :logfile = [$DS.USER_DIR/bench.log] if (fexist($logfile) == 1) { @ rename($logfile $logfile\.old) } ^window new name bench level crap hide swap last window logfile $DS.USER_DIR/bench.log log on for cmd in ($aliasctl(alias match bench.)) { $cmd $iter } window log off ^local foo $"Kill benchmark window? " if (tolower($foo) == [y]) { ^window kill } } alias tabkey.cmd.bench { bless if (curword == 1) { @ :ret = [ ] } else if (curword == 2) { @ :ret = tabkey.method.commands($*) } else { @ :ret = tabkey.method.nickchan($*) } return $ret } alias bench.assign (iter default "5000", void) { echo [ bench.assign start $strftime(%c) ] bench $iter ^assign foo $N bench $iter @ foo = [$N] bench $iter @ ::foo = [$N] bench $iter ^assign foo \$N bench $iter @ foo = N bench $iter @ foo = [\$N] ^assign -foo echo [ bench.assign finished $strftime(%H:%M:%S) ] } alias bench.if (iter default "5000", void) { echo [ bench.if start $strftime(%c) ] bench $iter if (N == servernick()) {#} bench $iter if (match($N $servernick())) {#} bench $iter if (findw($N $servernick())) {#} bench $iter if ((:nick = N) == servernick()) {#} bench $iter \${N == servernick() ? [] : []} bench $iter \${match($N $servernick()) ? [] : []} echo [ bench.if finished $strftime(%H:%M:%S) ] } alias bench.local (iter default "5000", void) { echo [ bench.local start $strftime(%c) ] bench $iter ^local foo $N bench $iter @ :foo = [$N] bench $iter ^local foo \$N bench $iter @ :foo = N bench $iter @ :foo = [\$N] echo [ bench.local finished $strftime(%H:%M:%S) ] } alias bench.loops (iter default "100", void) { echo [ bench.loops start $strftime(%c) ] bench $iter for (@ :cnt = 0, cnt < 101, @ cnt++) {#} bench $iter for cnt from 0 to 100 {#} bench $iter ^local cnt 0\;while (cnt < 101) {@ cnt++} echo [ bench.loops finished $strftime(%H:%M:%S) ] } alias bench.push (iter default "5000", void) { echo [ bench.push start start $strftime(%c) ] bench $iter ^local foo\;push foo $N bench $iter ^local foo\;@ push(foo $N) echo [ bench.push finished $strftime(%H:%M:%S) ] } /* EOF */