lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Guys
 
Thanks for all the prompt and interesting replies.
 
To answer the one question, I am probably going to use the data on the Lua side to construct a CSV file and spit it out on a serial port or maybe FTP it as a file. I might even have a crack at plotting a graph using the Lua Google Data Visualisation library. It all rather depends how badly my puny little processor complains about having too much work to do !
 
This is one example where Lua not having an option for 8 or 16 bit number sizes will cost me badly on execution time. I hope Roberto is still thinking optional smaller number types is a good feature for 5.3. I am more enthusiastic about that one possible change than all the features in 5.2 put together. Anyway I digress.
 
Now I have read the replies, I am favouring the individual big tables approach
 
myTime = mySamples.time[434]
myValue = mySamples.value[434]
 
This is quite readable, so I will code it up soon and see how fast it is. I will post some numbers when I have done it for reference.
 
Regards Geoff
 
> Date: Fri, 7 Jun 2013 18:10:13 +0200
> From: david@dkolf.de
> To: lua-l@lists.lua.org
> Subject: Re: Fastest way to transfer data from C to Lua ?
>
> Tim Hill wrote:
> > One thing to be aware of if you are running on a *really* resource
> > constrained system is that you are better off with fewer, bigger,
> > tables. Consider storing 1000 (x,y) pairs. The obvious way to do this is
> > to store 1000 {x,y} tables in an array. However, although it's not as
> > elegant, you are better off storing this as two simple arrays of 1000
> > elements, one containing the x values, one the y. This second method
> > uses only two tables instead of 1,001.
> >
> > And yes, the code is FAR less readable. Also, of course, if you do use
> > this method, the whole keys vs indices argument goes away.
>
> Storing it in a few big arrays would also be my suggestion and I guess
> it could also be quite readable:
>
> myTime = mySamples.time[434]
> myValue = mySamples.value[434]
>
> Best regards,
>
> David Kolf
>
>