On Tue, Aug 9, 2011 at 8:47 PM, Paul McNett <[email protected]> wrote:
> On 8/9/11 2:51 PM, Ed Leafe wrote:
>> On Aug 9, 2011, at 4:49 PM, Jarvis, Matthew wrote:
>>
>>> Python vs FoxPro Smack Down!!
>>>
>>> I'd be curious which is faster at reading all the lines of something
>>> like a 100k line file...
>>
>>       Just reading? Or doing something interesting with the text?
>>
>>> Think you could benchmark that for us?
>>
>>       If only I had some way to run FoxPro. :)
>
> http://paulmcnett.com/vfp_python_smackdown
>
> I have a 159K file to read (Dabo's dGrid.py) and the python script to count 
> each line
> of the file, and each char in each line, and print the results to standard 
> output. I
> ran this twenty times on my server using python 2.5.1 and it took between 0.0 
> and .04
> seconds each time, although the 0.0 and .04 were outliers: most of the times 
> were
> like .003.
>
> If someone wants to write the equivalent VFP script I'll post it there, too.
>
> Paul

Well, I'm rustier at FoxPro than I care to admit, but here's a quick
draft. Folks feel free to poke at it and speed it up:

STORE 0 TO linecount, charcount

start = SECONDS()
hFile = FOPEN("dGrid.py",0)
DO WHILE NOT FEOF(hFile)
  theline = FGETS(hFile)
  linecount = linecount + 1
  charcount = charcount + LEN(theline)
ENDDO
elapsed = SECONDS() - start
FCLOSE(hFile)
? "Lines: "
??linecount
? "Characters: "
?? charcount
? "Elapsed: "
?? elapsed

First pass on an old Pentium-M machine and VFP 7 yields:

Lines: 5294
Characters: 157296
Elapsed: 0.050

Bear in mind that VFP is atrocious at benchmarking fractions of a
second. I believe the accuracy is around 1/50th of second.

-- 
Ted Roche
Ted Roche & Associates, LLC
http://www.tedroche.com

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/cacw6n4ssc9v0d6s7z09_68bwxqgftclayuqxxmceqzafgwq...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to