6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue May 14, 2024 9:10 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Benchmark
PostPosted: Wed Jun 09, 2021 1:13 pm 
Offline

Joined: Thu May 13, 2021 8:56 am
Posts: 25
Location: Hellevoetsluis-NL
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:
 : 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 


Top
 Profile  
Reply with quote  
 Post subject: Re: Benchmark
PostPosted: Wed Jun 09, 2021 5:32 pm 
Offline

Joined: Fri Apr 15, 2016 1:03 am
Posts: 136
Running a slightly hacked 6502 FIG FORTH on a 65816 simulator I get the following:
Code:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Benchmark
PostPosted: Wed Jun 09, 2021 5:34 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8433
Location: Southern California
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Benchmark
PostPosted: Sat Jun 12, 2021 5:32 pm 
Offline

Joined: Fri Apr 15, 2016 1:03 am
Posts: 136
Here is a modified version of the benchmark code.
It includes a checksum to help verify the processing is correct.
Code:
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron