Re: Eu Interpreted

new topic     » goto parent     » topic index » view thread      » older message » newer message

Derek,

Hi, I'm new to this forum.

I ran your suggestion thinking you'd be right....

But not so, "text = append(text,line) " is significantly faster than
"text &= line".

Thinking about the reasons why....
It would be due to the memory overhead of string concatenation as the
string grows.
Large string concatenation is highly memory intensive.
Whereas, using append() , its just a straight malloc() for the new
sequence.
Also, I read somewhere append() has been highly optimised to avoid
allocating memory on every pass.

Regards,
Ross



----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, August 15, 2001 5:52 AM
Subject: Re: Eu Interpreted


>
> Irv,
> just an idea, but why don't you see what difference this makes ...
>
> Use ...
>   else text &= line
>
> instead of ...
>   else text = append(text,line)
>
> My guess is it should be a lot faster because fewer sequences are
involved.
>
> ----- Original Message -----
> From: "Irv Mullins" <irvm at ellijay.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Wednesday, August 15, 2001 5:30 AM
> Subject: Re: Eu Interpreted
>
>
> >
> > On Tuesday 14 August 2001 12:50, Robert Craig wrote:
> > >
> > > Irv Mullins writes:
> > > > Reading a 10,500 line text file and sorting it100 times in
Euphoria
> takes
> > > > 9.38 seconds, the same task in Lua takes 9.61 seconds. Making
the sort
> > > > call via "dostring" instead of direct takes 9.62 seconds.
> > >
> > > Correct me if I'm wrong but this benchmark
> > > seems to consist of:
> > >
> > >   1. doing a bunch of I/O, where a large chunk of the time
> > >        will be spent inside the O/S, and also waiting for possible
> > >        mechanical motion of the disk. Interpreter speed is largely
> > >        irrelevant. The I/O time just dilutes the overall speed
> comparison.
> > >
> > >   2. sorting, where you compare a generic and *interpreted*
shell-sort
> > >       written in Euphoria, against a quick-sort routine *written
in
> > > compiled C*, i.e. the Lua *built-in function* for "sort".
> > >       In any case, for 10,500 items, the quick sort *algorithm*
should
> be
> > >       somewhat faster than shell sort.
> > >
> > > The fact that Euphoria wins the benchmark is remarkable.
> >
> > It certainly is. But, as you say, the disk access masks the
differences.
> > Once you take the disk access time away, the story is different.
> > Look at this one:
> >
> > Convert 10,564 lines of text (from listserver archive) to uppercase:
> > (Timing starts after text is loaded)
> >
> > Euphoria :  0.24 seconds
> > Lua:          0.02 seconds
> >
> > -------------------
> > -- Filesort.lua
> > -------------------
> >
> > lines = {}
> >
> > readfrom("lua.txt")
> > lines = read("*all")
> > readfrom()
> >
> > start = clock()
> > lines = strupper(lines)
> > fini = clock()
> >
> > print(lines) -- to verify all is upper case
> > print(format("%2.4f",fini-start))
> >
> > --------------------
> > -- Filesort.exu
> > --------------------
> > include wildcard.e
> >
> > atom fn, start, fini
> > sequence text
> > object line
> >
> > fn = open("lua.txt","r")
> > text = {}
> > while 1 do
> >   line = gets(fn)
> >   if atom(line) then exit
> >   else text = append(text,line)
> >   end if
> > end while
> >
> > start = time()
> > text = upper(text)
> > fini = time()
> >
> > printf(1,"Time required: %2.4f",fini-start)
> >
> > Regards,
> > Irv
> >
> >
> >
> >
> >
>
>
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu