>>>>Hi All,
>>>>
>>>>Not really a Fox question specifically but thought someone here might have an idea on this.
>>>>
>>>>I am wondering just how code execution speed of VFP compares to other languages such as Python and Ruby? Take for example the following 10million times loop:
>>>>
>>>>nStart = SECONDS()
>>>>a = 0
>>>>b = RAND()
>>>>FOR x = 1 TO 10000000
>>>> a = a + b
>>>>NEXT
>>>>nStop = SECONDS()
>>>>? nStop-nStart, X, a
>>>>
>>>>
>>>>This runs on my machine in VFP in 2.4secs. Any idea how fast it would run in either of the alternative languages?
>>>>
>>>>Thanks,
>>>
>>>I'm not a process timer guru, but as a brain exercise decided to try your code in VFP 9 and what I think is a similar process in C# on my box -
>>>
>>>i7 cpu 1.73 ghz
>>>6 gb ram
>>>Win 7 64 bit
>>>
>>>Your code in my vfp 9 sp 2
>>>
>>>6.9 to 7.9 seconds on ten tests
>>>using 100,000,000 in the loop - 79.889 seconds
>>>
>>>This is my C# test :
>>>
>>>
>>>
>>> static void Main(string[] args)
>>> {
>>> Random random = new Random();
>>> int a = 0;
>>> int b = random.Next();
>>> Stopwatch stopwatch = new Stopwatch();
>>> stopwatch.Start();
>>> for (int i = 0; i < 10000000; i++)
>>> {
>>> a += b;
>>> }
>>>
>>> stopwatch.Stop();
>>>
>>> TimeSpan elapsedTime = stopwatch.Elapsed;
>>> Console.WriteLine(elapsedTime.ToString());
>>> Console.Read();
>>> }
>>>
>>>
>>>This does the 10,000,000 loop in .06 seconds.
>>>
>>>It appears your VFP code only generates one random number, so I tried to emulate that. If i move the generation of the random number inside the loop
>>>
>>>a += random.New();
>>>
>>>the whole process takes between .44 and .48 seconds.
>>>
>>>Since I know as a matter of catechism that nothing is faster than the Fox, I am sure my methodology must be flawed, but I find it interesting, nonethless and would welcome explanation.
>>
>>IAC I think you're lucky that a didn't overflow {g}
>
>I'd also be kind of curious as to why my VFP testing was getting 7+ second numbers where Nick got less than 3 ? ( see my specs )
>
>Nick, what are you running?
Charles,
Running on an 18 month old workstation but a reasonably fast one:
Win2003 Server - reasonably clean install
CPU: AMD Phenom II X6 - 2.8Ghz
RAM: 2 x 4Gb DDR3 1600Mhz
Nick