File:  [gforth] / gforth / siev.fs
Revision 1.1: download - view: text, annotated - select for diffs
Mon Nov 13 18:38:36 1995 UTC (23 years, 9 months 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

    1: \ #! /usr/stud/paysan/bin/forth
    2: 
    3: DECIMAL
    4: \ : SECS TIME&DATE  SWAP 60 * + SWAP 3600 * +  NIP NIP NIP ;
    5: CREATE FLAGS 8190 ALLOT
    6: variable eflag
    7: \ FLAGS 8190 + CONSTANT EFLAG
    8: 
    9: : PRIMES  ( -- n )  FLAGS 8190 1 FILL  0 3  EFLAG @ FLAGS
   10:   DO   I C@
   11:        IF  DUP I + DUP EFLAG @ <
   12:            IF    EFLAG @ SWAP
   13:                  DO  0 I C! DUP  +LOOP
   14:            ELSE  DROP  THEN  SWAP 1+ SWAP
   15:            THEN  2 +
   16:        LOOP  DROP ;
   17: 
   18: : BENCHMARK  0 1000 0 DO  PRIMES NIP  LOOP ;
   19: \ SECS BENCHMARK . SECS SWAP - CR . .( secs)
   20: : main 
   21: 	flags 8190 + eflag !
   22: 	benchmark ( . ) drop
   23: ;

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