From 690251a492b6af775e5f37141e4076f0f609928d Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Mon, 28 Oct 2019 10:34:24 -0700 Subject: [PATCH 1/2] update with raw timing, cleaned up timing code This version cleans up the timing code to make it more readable. Adds a raw TIME and ADJUSTED time column to the output. Fixed issues with inter-test timing. Oleg's version was trying to store the results of one test to inform future tests (aka: use integer assignment to deduct the results of integer addition later), but this wasn't actually working. Future suggestions: * Add integer% tests to compare manipulating int% types * Add tests with $hex and %binary literals --- basic/basic-benchmark.bas | 85 +++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/basic/basic-benchmark.bas b/basic/basic-benchmark.bas index d23b4a8..de2a235 100644 --- a/basic/basic-benchmark.bas +++ b/basic/basic-benchmark.bas @@ -1,95 +1,100 @@ -1 PRINT CHR$(147); - -10 FF = 1000: REM NUMBER OF EXECUTIONS TO GET AVERAGE - +0 REM BASIC-BENCHMARK.BAS BY OLEG-IMANILOV +1 REM UPDATES BY TOM WILSON FOR RAW/ADJUSTED TIME +9 REM GITHUB.COM/COMMANDERX16/X16-DEMO +10 PRINT CHR$(147); +15 FF=1250: REM NUMBER OF EXECUTIONS TO GET AVERAGE 20 TXT$ = "EMPTY FOR LOOP" 30 T0=TI 40 FOR I=0 TO FF +45 REM 50 NEXT 55 T1 = TI -60 Z0 = T1-T0: REM ZERO TIME -70 IF Z0<10 THEN PRINT "WARNING: ZERO TIME IS TOO LOW, INCREASE FF!" - -73 PRINT "------------------------------+------------" -75 PRINT " OPERATION : OP/SEC " -80 PRINT "------------------------------+------------" - -90 Z = 0 -95 GOSUB 32000 - +60 PRINT "--------------------------+------------+------+----------- +62 PRINT " OPERATION : OP/SEC : TIME : ADJUSTED +64 PRINT "--------------------------+------------+------+----------- +70 GOSUB 32000 +75 PRINT " : : : +80 Z=T1-T0:Z0=Z:REM ZERO TIME +90 IF Z<10 THEN PRINT "WARNING: ZERO TIME IS TOO LOW, INCREASE FF!" 110 TXT$ = "SMALL INT ASSIGNMENT" -120 Z = Z0: A = 0 +120 A = 0 130 T0 = TI 140 FOR I=0 TO FF -150 A = 13 +150 A = 55 160 NEXT -170 T1=TI: ZI0 = (T1-T0)-Z0 +170 T1=TI 180 GOSUB 32000 - +190 ZI=TE:REM SAVE FOR LATER (TO REMOVE THIS FROM "ADD SMALL INT") 210 TXT$ = "BIG INT ASSIGNMENT" -220 Z = Z0: A = 100000 +220 A = 100000 230 T0 = TI 240 FOR I=0 TO FF 250 A = 100000 260 NEXT -270 T1=TI: ZI1 = (T1-T0)-Z0 +270 T1=TI 280 GOSUB 32000 - +290 ZL=TE 310 TXT$ = "FLOAT ASSIGNMENT" -320 Z = Z0: A = 123.456 +320 A = 123.456 330 T0 = TI 340 FOR I=0 TO FF -350 A = 123.456 +350 A = 1234.5678 360 NEXT -370 T1=TI: ZF = (T1-T0)-Z0 +370 T1=TI 380 GOSUB 32000 - +390 ZF=TE 410 TXT$ = "SMALL INT ADD" -420 Z = Z0: A = 3 +420 A = 3 430 T0 = TI 440 FOR I=0 TO FF -450 A = 5+7 +450 A = 1+1 460 NEXT 470 T1=TI +475 Z=ZI 480 GOSUB 32000 - +490 Z=Z0 510 TXT$ = "BIG INT ADD" -520 Z = Z0: A = 3 +520 A = 3 530 T0 = TI 540 FOR I=0 TO FF 550 A = 500+700 560 NEXT 570 T1=TI +575 Z=ZL 580 GOSUB 32000 - +590 Z=Z0 610 TXT$ = "FLOAT ADD" -620 Z = ZF: A = 123.456 +620 A = 123.456:B=123.456 630 T0 = TI 640 FOR I=0 TO FF -650 A = 500.123+700.456 +650 A = 12.34+12.34 660 NEXT 670 T1=TI +675 Z=ZF 680 GOSUB 32000 - +690 Z=Z0 710 TXT$ = "SIN" -720 Z = ZF: A = 123.456 +720 A = 123.456 730 T0 = TI 740 FOR I=0 TO FF 750 A = SIN(1.23) 760 NEXT 770 T1=TI 780 GOSUB 32000 - 810 TXT$ = "SMALL NUMBER POWER" -820 Z = ZI0: A = 10 +820 A = 10 830 T0 = TI 840 FOR I=0 TO FF 850 A = 2^3 860 NEXT 870 T1=TI +875 Z=ZI 880 GOSUB 32000 - 31999 END -32000 PRINT LEFT$(TXT$+" ",30);":"; -32010 PRINT (FF/((T1-T0-Z)/60)) -32020 RETURN +32000 PRINT TXT$;TAB(26);":"; +32010 TE=T1-T0:TA=TE-Z:REM ELAPSED, ADJUSTED TIME +32020 PRINT FF/TA*60; +32030 PRINT TAB(39);":";TE; +32040 PRINT TAB(46);":";TA; +32050 PRINT +32060 RETURN From 8131dc238d0e700aae1d8d291fc70827295fbf6d Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Thu, 11 Jan 2024 22:39:15 -0800 Subject: [PATCH 2/2] Simple clock program w/graphics --- basic/CLOCK.BAS | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 basic/CLOCK.BAS diff --git a/basic/CLOCK.BAS b/basic/CLOCK.BAS new file mode 100644 index 0000000..fe83e46 --- /dev/null +++ b/basic/CLOCK.BAS @@ -0,0 +1,45 @@ +10 SCREEN $80 +20 COLOR 1 +30 C=0:XC=160:YC=120:R=90:R1=100:R2=110 +40 BANK 1 +50 RECT 0,0,319,239,0 +60 REM CLOCK +70 AI=2*\XFF/60 +80 A1=0:A2=\XFF*2 +90 C=1 +100 FOR I=A1+AI*5 TO A2 STEP AI*5 +110 XR=SIN(I)*R+XC +120 XT=SIN(I)*R1+XC +130 XU=SIN(I)*R2+XC +140 YR=-COS(I)*R+YC +150 YT=-COS(I)*R1+YC +160 YU=-COS(I)*R2+YC +170 LINE XR,YR,XT,YT,3 +180 CHAR XU-6,YU+3,1,STR$(C) +190 C=C+1 +200 NEXT +210 REM CLOCK +220 T$=TI$ +230 HH=VAL(MID$(T$,1,2)) +240 MM=VAL(MID$(T$,3,2)) +250 SS=VAL(MID$(T$,5,2)) +260 TT$=LEFT$(T$,2)+":"+MID$(T$,3,2)+":"+RIGHT$(T$,2) +270 LINE XC,YC,XS,YS,0 +280 LINE XC,YC,XM,YM,0 +290 LINE XC,YC,XH,YH,0 +300 AA=AI*SS +310 XS=SIN(AA)*R+XC +320 YS=-COS(AA)*R+YC +330 LINE XC,YC,XS,YS,14 +340 AA=AI*MM +350 XM=SIN(AA)*R*.8+XC +360 YM=-COS(AA)*R*.8+YC +370 LINE XC,YC,XM,YM,4 +380 AA=AI*HH*2.5 +390 XH=SIN(AA)*R*.6+XC +400 YH=-COS(AA)*R*.6+YC +410 LINE XC,YC,XH,YH,5 +420 RECT XC-18,YC+5,XC+18,YC-5,0 +430 CHAR XC-17,YC+3,1,TT$ +440 IF T$=TI$ THEN 440 +450 GOTO 220