File:  [gforth] / gforth / siev.fs
Revision 1.1: download - view: text, annotated - select for diffs
Mon Nov 13 18:38:36 1995 UTC (22 years, 1 month ago) by anton
Branches: MAIN
CVS tags: v0-7-0, v0-6-2, v0-6-1, v0-6-0, v0-5-0, v0-4-0, v0-3-0, v0-2-1, v0-2-0, gforth-0_1beta, HEAD
added benchmark files

\ #! /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
;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>