Commit c2b570bb authored by anton's avatar anton

added benchmark files

parent 529d3d7c
Some benchmark results for various combinations of hardware, Gforth
version, and Gforth configuration. You can measure your combination
with `make bench'. You can find a table comparing Gforth with four
interpretive Forth systems in the manual (Section Performance), and a
comparison with more systems in
http://www.complang.tuwien.ac.at/pub/papers/ertl&maierhofer95.ps.gz.
All times are given in seconds of user time.
siev bubble matrix fib machine and configuration
10.99 12.13 11.34 13.13 Pentium 133MHz 256K PB cache; gcc-2.6.3 -DFORCE_REG; gforth-0.1beta
31.90 35.60 28.30 36.70 i486 66MHz 256K cache; gcc-2.6.3 -DFORCE_REG; gforth-0.1alpha
\ .( Loading Bubble Sort benchmark...) cr
\ A classical benchmark of an O(n**2) algorithm; Bubble sort
\
\ Part of the programs gathered by John Hennessy for the MIPS
\ RISC project at Stanford. Translated to forth by Marty Fraeman
\ Johns Hopkins University/Applied Physics Laboratory.
\ MM forth2c doesn't have it !
: mybounds over + swap ;
variable seed ( -- addr)
: initiate-seed ( -- ) 74755 seed ! ;
: random ( -- n ) seed @ 1309 * 13849 + 65535 and dup seed ! ;
6000 constant elements ( -- int)
align create list elements cells allot
: initiate-list ( -- )
list elements cells + list do random i ! cell +loop
;
: dump-list ( -- )
list elements cells + list do i @ . cell +loop cr
;
: verify-list ( -- )
list elements 1- cells mybounds do
i 2@ > abort" bubble-sort: not sorted"
cell +loop
;
: bubble ( -- )
\ ." bubbling..." cr
1 elements 1 do
list elements i - cells mybounds do
i 2@ > if i 2@ swap i 2! then
cell +loop
loop
;
: bubble-sort ( -- )
initiate-seed
initiate-list
bubble
verify-list
;
: bubble-with-flag ( -- )
1 elements 1 do
-1 list elements i - cells mybounds do
i 2@ > if i 2@ swap i 2! drop 0 then
cell +loop
if leave then
loop
;
: bubble-sort-with-flag ( -- )
initiate-seed
initiate-list
bubble-with-flag
verify-list
;
: main ( -- )
bubble-sort
\ bubble-sort-with-flag
;
: fib ( n1 -- n2 )
dup 2 < if
drop 1
else
dup
1- recurse
swap 2 - recurse
+
then ;
: main 34 fib drop ;
\ No newline at end of file
\ .( Loading Matrix Multiplication benchmark...) cr
\ NOTE: This version needs 0.5MB data space
\ A classical benchmark of an O(n**3) algorithm; Matrix Multiplication
\
\ Part of the programs gathered by John Hennessy for the MIPS
\ RISC project at Stanford. Translated to forth by Marty Fraeman,
\ Johns Hopkins University/Applied Physics Laboratory.
\ MM forth2c doesn't have it !
: mybounds over + swap ;
variable seed
: initiate-seed ( -- ) 74755 seed ! ;
: random ( -- n ) seed @ 1309 * 13849 + 65535 and dup seed ! ;
200 constant row-size
row-size cells constant row-byte-size
row-size row-size * constant mat-size
mat-size cells constant mat-byte-size
align create ima mat-byte-size allot
align create imb mat-byte-size allot
align create imr mat-byte-size allot
: initiate-matrix ( m[row-size][row-size] -- )
mat-byte-size mybounds do
random dup 120 / 120 * - 60 - i !
cell +loop
;
: innerproduct ( a[row][*] b[*][column] -- int)
0 row-size 0 do
>r over @ over @ * r> + >r
cell+ swap row-byte-size + swap
r>
loop
>r 2drop r>
;
: main ( -- )
initiate-seed
ima initiate-matrix
imb initiate-matrix
imr ima mat-byte-size mybounds do
imb row-byte-size mybounds do
j i innerproduct over ! cell+
cell +loop
row-size cells +loop
drop
;
\ #! /usr/stud/paysan/bin/forth
DECIMAL
\ : SECS TIME&DATE SWAP 60 * + SWAP 3600 * + NIP NIP NIP ;
CREATE FLAGS 8190 ALLOT
variable eflag
\ FLAGS 8190 + CONSTANT EFLAG
: PRIMES ( -- n ) FLAGS 8190 1 FILL 0 3 EFLAG @ FLAGS
DO I C@
IF DUP I + DUP EFLAG @ <
IF EFLAG @ SWAP
DO 0 I C! DUP +LOOP
ELSE DROP THEN SWAP 1+ SWAP
THEN 2 +
LOOP DROP ;
: BENCHMARK 0 1000 0 DO PRIMES NIP LOOP ;
\ SECS BENCHMARK . SECS SWAP - CR . .( secs)
: main
flags 8190 + eflag !
benchmark ( . ) drop
;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment