1. Re: EU to C translator

On Wednesday 25 July 2001 10:06, jstory at freenet.edmonton.ab.ca wrote:

> > I think a big part of the delay is caused by using
> > and parsing a text file. Have you tried saving and loading the
> > data in native Euphoria sequence format? Or better, using
> > print.e?
>
>   I don't understand.  What is Euphoria sequence format?  What does
> print.e do?

Let's take the first line of your 2.3 meg food file:
~01001~^~BUTTER,WITH
SALT~^15.870^717.000^.850^81.110^.060^0.000^2.110^24.000^23.000^.160^826.000^26.000^2.000^.050^.016^.004^1.000^3058.000^1.580^.005^.034^.042^.110^.003^3.000^.125^0.000^50.489^23.426^3.012^218.900^227.000^~1
cup~^14.200^~1
tablespoon~^0^0.012000^0.038000^0.051000^0.083000^0.067000^0.021000^0.008000^0.041000^0.041000^0.057000^0.031000^0.023000^0.029000^0.064000^0.178000^0.018000^0.082000^0.046000

That's a long line, no telling what EuForum will do to it :)
Anyway, you're reading and parsing each of those 6210 lines, 
when they could all be written as a single block of data using 
include print.e 
print(fn, data)

{{"01001","BUTTER, WITH
SALT",15.87,717,850,81.11,60,0,2.11,24,23,160,826,26,2,.05,........}}

Ok, I got tired of typing, but you can already see that this takes less room
than the original,
and is just as readable (maybe more so)

Reading the data in is just a matter of using
data = get(fn)
if data[1] = GET_SUCCESS then data = data[2]
else -- error routine

This is *much* faster than reading line by line, using gets(), plus 
there would be no parsing to do.

Running profile on your program shows that it wastes a lot of  
CPU cycles - over 2,449.000 times thru the parsing loop  (at least, 
I guess that's what you are doing with the '^' characters) 
Without further dissecting your program, I can't see why you 
would need to parse anything at all.

> > You might also consider using EDS, and only loading the data
> > you need at the moment.
>
>   Need all of it always.

Not likely - windows scroll boxes can only show a limited amount of 
data, plus you allow the user to select food groups, so that again 
limits the amount of data that has to be loaded at any given time.
If you were to load data as needed, using EDS, for example, I 
would expect both startup and response to be near instantaneous. 

Regards,
Irv

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu