Benchmark

Topics relating to various Forth models on the 6502, 65816, and related microprocessors and microcontrollers.
Post Reply
Powersoft
Posts: 31
Joined: 13 May 2021
Location: Hellevoetsluis-NL

Benchmark

Post by Powersoft »

Hello,

I wont to know the time that benchmark needs to run 200 benchmark on a 1 mhz 6502. So I can compare it with the time need with a 6502 emulator running fig-forth on a esp32.

Cheers,

Jan

Code: Select all

 : ggd ( a b -- ggd )
    begin
      dup
    while
      swap over mod
    repeat
    drop 
  ;
: benchmark ( n -- )  
    dup  
    0 do  
    dup 0 do  
      j i ggd drop  
      loop  
    loop  
    drop  
;  
leepivonka
Posts: 168
Joined: 15 Apr 2016

Re: Benchmark

Post by leepivonka »

Running a slightly hacked 6502 FIG FORTH on a 65816 simulator I get the following:

Code: Select all

D:\65816\Fig8>\65816s\release\65816s 0265sxb.lst
65816S Apr  8 2021 15:52:05
65c265 mode on
A=0000 X=0000 Y=0000 S=0180 EnvMXdIzc D=0000 B=00 EA4C8E14 000300 nop
.g

fig-FORTH 1.1 modified

A=00FE X=00EF Y=0000 S=01F5 ENvMXdIzC D=0000 B=00 58B0F860 000653 cli
.@..\f_benchggd.txt
.g
( http://forum.6502.org/viewtopic.php?f=9&t=6637 ) OK
 OK
: ggd ( a b -- ggd )
   begin
     dup
   while
     swap over mod
   repeat
   drop
  ; OK
: benchmark ( n -- )
    dup
    0 do
    dup 0 do
      j i ggd drop
      loop
    loop
    drop
  ; eof
 OK
cc@ 5 benchmark cc@ d- d. -339733 OK
cc@ 10 benchmark cc@ d- d. -1081868 OK
cc@ 20 benchmark cc@ d- d.  -4984708 OK
cc@ reads the simulator cycle counter as a double (limited to 24 bits on this setup).
Doing 200 benchmark runs far longer than the 16777216 cycles where cc@ wraps.

1081868 cycles at 1MHz would be 1.081868 secs.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Benchmark

Post by GARTHWILSON »

Be aware than MOD uses UM/MOD (I think it's called U/ in figForth) which has a bug in it. See http://6502.org/source/integers/ummodfix/ummodfix.htm for the fix.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
leepivonka
Posts: 168
Joined: 15 Apr 2016

Re: Benchmark

Post by leepivonka »

Here is a modified version of the benchmark code.
It includes a checksum to help verify the processing is correct.

Code: Select all

0 variable ChkSum

: ggd ( a b -- ggd )
   begin
     dup
   while
     swap over mod
     dup ChkSum +!
   repeat
   drop
  ;
: benchmark ( n -- ) 
  0 ChkSum !
  dup 0 do
    dup 0 do 
      j i ggd drop 
      loop 
    loop 
  drop
  ChkSum @ .
  ;
I've fixed my cc@ so it returns 32 bits of cycle counter, so I can time longer runs.

Here are my results for various FORTHs:

FIG modified 8bit Indirect-Threaded -------------------
104 bytes
cc@ 200 benchmark cc@ d- d. 748 -1023891113 OK 1024 sec @ 1MHz
3000000003. 50003 u/ . . -5540 20015 OK

FIG modified 8bit Subroutine-Threaded --------------------
133 bytes
cc@ 200 benchmark cc@ d- d. 748 -382665927 OK 383 sec @ 1MHz
3000000003. 50003 um/mod . . -5540 20015 OK

FIG modified 16bit Indirect-Threaded -------------------
104 bytes
cc@ 200 benchmark cc@ d- d. 748 -485138841 OK 485 sec @ 1MHz
3000000003. 50003 u/ . . -5540 20015 OK

FIG modified 16bit Subroutine-Threaded -------------------
136 bytes
cc@ 200 benchmark cc@ d- d. 748 -192266443 OK 192 sec @ 1MHz
3000000003. 50003 u/ . . -5540 20015 OK

65816F 16bit Subroutine-Threaded ------------------
140 bytes
cc@ 200 benchmark cc@ d- d. 748 -117452133 ok 117 sec @ 1MHz
3000000003. 50003 um/mod . . -5540 20015 ok

Tali 8bit Subroutine-Threaded ---------------------
410 bytes
cc@ 200 benchmark cc@ d- d. 748 -369954558 ok 370 sec @ 1MHz
3000000003. 50003 um/mod . . -5540 20015 ok

GForth-fast on x64 --------------------
200 benchmark 748 ok
3000000003. 50003 um/mod . . 59996 20015 ok
Post Reply