The LeapYear
#11
Quote:If PBDOS had $REGISTER NONE I'd have used it just to make sure. Also, "make it work first", then try reversible changes.

This must be later stuff.

In PB 3.5, I only read about Push an Pop for putting things on and from  the stack.
But the registers - normaly - don't need to be pushes and poped.

I optimized both routines:
  • Your Inline-Asm-Routine by commenting pushes and pops of registers out.
  • My BASIC-Routine by using two of your tips.

I tested these new versions on DOSBox and DOSEmu:
Code:
Testing the speed of optimized leapyear calculaition in (Power)BASIC and Inline-Asm
Old = not optimized
New =    optimized

Old: 03-08-2025    24:26:54      Linux - DOSBox German numbers!
New: 03-09-2025    16:12:07      Linux - DOSBox German numbers!

Old:
Test 1, part 1: Calculating 65535 times in BASIC-Code:
2000 leap? yes - Test took 4.394.786,000 Millisekunden
Test 1, part 2: Calculating 65535 times in Inline-Asm-Code:
2000 leap? yes - Test took 1.048.882,000 Millisekunden
Inline-Asm is      4,189972 times faster here
New:
Test 1, part 1: Calculating 65535 times in BASIC-Code:
2000 leap? yes - Test took 4.370.582,000 Millisekunden
Test 1, part 2: Calculating 65535 times in Inline-Asm-Code:
2000 leap? yes - Test took  917.768,000 Millisekunden
Inline-Asm is      4,762186 times faster here

Old:
Test 2, part 1: Calculating 65535 times in BASIC-Code:
2100 leap? no  - Test took 4.370.329,000 Millisekunden
Test 2, part 2: Calculating 65535 times in Inline-Asm-Code:
2100 leap? no  - Test took  961.471,000 Millisekunden
Inline-Asm is      4,545461 times faster here
New:
Test 2, part 1: Calculating 65535 times in BASIC-Code:
2100 leap? no  - Test took 4.348.479,000 Millisekunden
Test 2, part 2: Calculating 65535 times in Inline-Asm-Code:
2100 leap? no  - Test took  830.365,000 Millisekunden
Inline-Asm is      5,236828 times faster here

Old:
Test 3, part 1: Calculating 65535 times in BASIC-Code:
2104 leap? yes - Test took 4.392.178,000 Millisekunden
Test 3, part 2: Calculating 65535 times in Inline-Asm-Code:
2104 leap? yes - Test took  961.471,000 Millisekunden
Inline-Asm is      4,568186 times faster here
New:
Test 3, part 1: Calculating 65535 times in BASIC-Code:
2104 leap? yes - Test took 4.370.328,000 Millisekunden
Test 3, part 2: Calculating 65535 times in Inline-Asm-Code:
2104 leap? yes - Test took  830.365,000 Millisekunden
Inline-Asm is      5,263141 times faster here

Old:
Test 4, part 1: Calculating 65535 times in BASIC-Code:
2103 leap? no  - Test took 4.370.327,000 Millisekunden
Test 4, part 2: Calculating 65535 times in Inline-Asm-Code:
2103 leap? no  - Test took  721.107,000 Millisekunden
Inline-Asm is      6,060580 times faster here
New:
Test 4, part 1: Calculating 65535 times in BASIC-Code:
2103 leap? no  - Test took 4.348.479,000 Millisekunden
Test 4, part 2: Calculating 65535 times in Inline-Asm-Code:
2103 leap? no  - Test took  677.403,000 Millisekunden
Inline-Asm is      6,419338 times faster here

Old:
Test 5, part 1: Calculating 65535 times in BASIC-Code:
1204 leap? yes - Test took  830.365,000 Millisekunden
Test 5, part 2: Calculating 65535 times in Inline-Asm-Code:
1204 leap? yes - Test took  721.107,000 Millisekunden
Inline-Asm is      1,151514 times faster here
New:
Test 5, part 1: Calculating 65535 times in BASIC-Code:
1204 leap? yes - Test took 1.136.285,000 Millisekunden
Test 5, part 2: Calculating 65535 times in Inline-Asm-Code:
1204 leap? yes - Test took  677.402,000 Millisekunden
Inline-Asm is      1,677416 times faster here

Old:
Test 6, part 1: Calculating 65535 times in BASIC-Code:
1201 leap? no  - Test took  808.510,000 Millisekunden
Test 6, part 2: Calculating 65535 times in Inline-Asm-Code:
1201 leap? no  - Test took  699.252,000 Millisekunden
Inline-Asm is      1,156250 times faster here
New:
Test 6, part 1: Calculating 65535 times in BASIC-Code:
1201 leap? no  - Test took 1.114.435,000 Millisekunden
Test 6, part 2: Calculating 65535 times in Inline-Asm-Code:
1201 leap? no  - Test took  655.547,000 Millisekunden
Inline-Asm is      1,700008 times faster here



Old: 03-09-2025    00:27:32      Linux - DOSEmu German numbers!
New: 03-09-2025    16:12:44      Linux - DOSEmu German numbers!

Old:
Test 1, part 1: Calculating 65535 times in BASIC-Code:
2000 leap? yes - Test took  131.325,000 Millisekunden
Test 1, part 2: Calculating 65535 times in Inline-Asm-Code:
2000 leap? yes - Test took    13.212,000 Millisekunden
Inline-Asm is      9,939827 times faster here
New:
Test 1, part 1: Calculating 65535 times in BASIC-Code:
2000 leap? yes - Test took  131.983,000 Millisekunden
Test 1, part 2: Calculating 65535 times in Inline-Asm-Code:
2000 leap? yes - Test took    12.119,000 Millisekunden
Inline-Asm is    10,890585 times faster here

Old:
Test 2, part 1: Calculating 65535 times in BASIC-Code:
2100 leap? no  - Test took  126.944,000 Millisekunden
Test 2, part 2: Calculating 65535 times in Inline-Asm-Code:
2100 leap? no  - Test took    12.813,000 Millisekunden
Inline-Asm is      9,907438 times faster here
New:
Test 2, part 1: Calculating 65535 times in BASIC-Code:
2100 leap? no  - Test took  133.757,000 Millisekunden
Test 2, part 2: Calculating 65535 times in Inline-Asm-Code:
2100 leap? no  - Test took    11.826,000 Millisekunden
Inline-Asm is    11,310418 times faster here

Old:
Test 3, part 1: Calculating 65535 times in BASIC-Code:
2104 leap? yes - Test took  127.343,000 Millisekunden
Test 3, part 2: Calculating 65535 times in Inline-Asm-Code:
2104 leap? yes - Test took    12.585,000 Millisekunden
Inline-Asm is    10,118633 times faster here
New:
Test 3, part 1: Calculating 65535 times in BASIC-Code:
2104 leap? yes - Test took  132.773,000 Millisekunden
Test 3, part 2: Calculating 65535 times in Inline-Asm-Code:
2104 leap? yes - Test took    12.150,000 Millisekunden
Inline-Asm is    10,927819 times faster here

Old:
Test 4, part 1: Calculating 65535 times in BASIC-Code:
2103 leap? no  - Test took  127.684,000 Millisekunden
Test 4, part 2: Calculating 65535 times in Inline-Asm-Code:
2103 leap? no  - Test took    10.438,000 Millisekunden
Inline-Asm is    12,232612 times faster here
New:
Test 4, part 1: Calculating 65535 times in BASIC-Code:
2103 leap? no  - Test took  134.417,000 Millisekunden
Test 4, part 2: Calculating 65535 times in Inline-Asm-Code:
2103 leap? no  - Test took    10.288,000 Millisekunden
Inline-Asm is    13,065416 times faster here

Old:
Test 5, part 1: Calculating 65535 times in BASIC-Code:
1204 leap? yes - Test took    13.623,000 Millisekunden
Test 5, part 2: Calculating 65535 times in Inline-Asm-Code:
1204 leap? yes - Test took    11.585,000 Millisekunden
Inline-Asm is      1,175917 times faster here
New:
Test 5, part 1: Calculating 65535 times in BASIC-Code:
1204 leap? yes - Test took    26.605,000 Millisekunden
Test 5, part 2: Calculating 65535 times in Inline-Asm-Code:
1204 leap? yes - Test took    11.015,000 Millisekunden
Inline-Asm is      2,415343 times faster here

Old:
Test 6, part 1: Calculating 65535 times in BASIC-Code:
1201 leap? no  - Test took    14.706,000 Millisekunden
Test 6, part 2: Calculating 65535 times in Inline-Asm-Code:
1201 leap? no  - Test took    10.805,000 Millisekunden
Inline-Asm is      1,361037 times faster here
New:
Test 6, part 1: Calculating 65535 times in BASIC-Code:
1201 leap? no  - Test took    29.491,000 Millisekunden
Test 6, part 2: Calculating 65535 times in Inline-Asm-Code:
1201 leap? no  - Test took    13.127,000 Millisekunden
Inline-Asm is      2,246591 times faster here

Apart from test 6 on DOSEmu, the optimized routines are slightly faster.
The BASIC-Code got slower in Test 5 and 6 on DOSBox und DOSEmu.

Mostly, I will have to calculate in Gregorian ages…
Reply
#12
"But the registers - normaly - don't need to be pushes and poped."

If mixing ASM with BASIC in a FUNCTION or SUB you do PUSH/POP the registers used because we do not know which registers the compiler used for BASIC. As I was not absolutely sure what the compiler would do with iJahr I put them in.

I guess that is it for this job, it works and is fast.

Cheers,
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)