I have 2 machines with F # 2.0 Interactive build 4.0.30319.1 on vs 2010. Some of my programs ran much slower on a faster machine. The problem is that integer arithmetic performance on 32-bit Windows is significantly slower than 64 Windows.
On a slightly slower 64-bit Windows 7 machine (program listed below):
primeCount = 1270607
Real: 00: 00: 07.553, CPU: 00: 00: 07.519, GC gen0: 0, gen1: 0, gen2: 0
On a slightly faster Windows XP SP2 machine:
primeCount = 1270607
Real: 00: 00: 32.800, CPU: 00: 00: 32.796, GC gen0: 0, gen1: 0, gen2: 0
Thus, the 32-bit version takes up more than 4 times to the 64-bit version. I assume that there is no significant difference due to different operating systems, except for the word length that is supported.
Program:
let isPrime(n) = if n < 2 then false elif (n % 2) = 0 then // take care of even case if n = 2 then true else false else // n is odd let ms = int(sqrt(float(n))) let rec isPrimeUtil(m) = if m > ms then true elif n % m = 0 then false else isPrimeUtil(m + 2) isPrimeUtil(3) let nums = [1 .. 20000000] let pcountref = ref 0 //
Send the program interactive. #time;; Then, to measure the elapsed time for processing, rather than generate a range of nums, select the line
let pcountref = ref 0
and all subsequent lines and send to interactive.
Dougt source share