Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to ask to get someone else assigned
Message
From
07/03/2013 06:17:27
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
07/03/2013 04:52:05
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01567409
Message ID:
01567693
Views:
39
>600x speedup is hard to crack - my best examples hover between 70 and 250...
>completing the package in less than twice the time the original runs is also a good measure

I had once reworked a parser to about 20x - didn't measure the speedup at all, as it was getting different files and the format kept changing, but, just for comparison:

- the original code read the text file using fread(), one byte at a time
- it did a lot of fseek() back and forth, frequently going one byte back, in an attempt to decide the delimiters.
- about 20 lines of code and a few more fseek()s were there just to determine end of line

Just rewriting this to fread() about 16k of text at a time, chop the text into lines and then use a few strtran()s to distinguish between comma-as-delimiter from comma-inside-text brought about 10x speedup.

Then it got interesting - the specs changed, and the incoming files didn't have a fixed structure anymore. Some columns may or may not be present, but if they were, there would have to be some code (for many of them) which would convert them (several of those contained something xml-like, i.e. multiple values in a special format). The routine had lots of "if column exists, thiscall() endif". So I wrote a little code generator, which would check for existence of each field, and include a line or two in the generated prg for each that was there, and omitted the absent. By my guesstimate, it saved about 40000 if-endif blocks on each run, just on columns which didn't occur regularly.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform