Lars writes:
Quote
I have not look in the prime code.
Ok i just testet you function.
And the IsPrimeHR_IA32_2 is almost 100 times faster than SZIsPrime !
IsPrimeHR_IA32_2 129 124 138 391
IsPrimeHR_IA32_1 191 210 219 620
IsPrimeJOH_IA32_6 189 213 222 624
IsPrimeJOH_IA32_4 255 260 271 786
IsPrimeDKCSSE_1 325 318 340 983
IsPrimeDKCIA32_9 330 321 344 995
IsPrimeDKCSSE_2 331 324 347 1002
IsPrimeDKCPas22 796 737 802 2335
IsPrimeJOHPas6 1020 1912 2403 5335
SZIsPrime 2580 14213 19530 36323
With all respect, your testing program do not show realistic algorithm
performance. I have lot of trouble with RDTSC on small testing
interval, expecially with large data manipulation befor and after test
starting what ever measure I to preserve process on higest priority -
is simply can not be done. That why i perfom at least 50 repeatitevly
testing cycles to get the most accurate possible value with simple
RDTSC command since any process preparation have no effect (see my
SZCodeBaseX and SZTimer unit). Before test, I close all backround
application as is AVP, etc.
About algorithm pefromance. Accordin to elemantary math prove, all
primes are in form n*6-1 or n*6+1, where n in natural number, except
for 2 and 3. According to that, instead of any second odd number check,
we have 2 times less attempts, which mean 2 time less time get result.
Of course, pascal realization of this algorithm can not compare with pure
ASM, but with all other pascal realisation.
About testing. I did performe real performance testing, searching
primes from 1 to 1.000.000, with setep 1 on 1.3MHz Celeron with
optimization On and OFF. Except the real speed performance, this way of
testing also prove correctness of all tested algorithm.
About used algorithm. The fastest John's IA32_6 ASM realization is a
reper. Dennis fastest Pass22 as well as John's Pas2 and pas6. My own
Pas1 is a raw algorithm you tested. As well as my Pas2 variatioiin with
equal number of predefined primes as in John's Pas6.
Results:
Prime number algorithm Time Up to Total
----------------------------------------------------------------
John O'Harrow IA32_6 00:00:02.373 10000000 664579
Dennis Christensen Pas22 00:00:27.920 10000000 664579
John O'Harrow Pas2 00:00:27.960 10000000 664579
Sasa Zeman Pas1 00:00:17.254 10000000 664579
John O'Harrow Pas6 00:00:24.143 10000000 664579
Sasa Zeman Pas2 00:00:15.592 10000000 664579
----------------------------------------------------------------
Column explanation:
Time : In milisecond resolution
Up to: Dearching for primes from 1 to 1.000.000 by 1 step
Total: Total number of primes from up to given number
I did post testing program to attachment group.
Apologies to John, since I wrote his last name incorrectly in previous
message.
Sasa
--
www.szutils.net