[DUG] Saving aray
John Bird
johnkbird at paradise.net.nz
Tue Jul 8 09:27:18 NZST 2014
Currently its about 0 to 170, but may expand in future, so a byte array could be used as well at least at present. I will run a test on both byte and word and integer to see. If its only a second or two its fine. And there are no pointers, otherwise I wouldn’t even consider it.
I thought there must be some simple way to do it with Filestream, only I haven’t done it with binary data like this (I didn’t plan for needing this when I designed it)
I can live with the 40-50 seconds delay, but on PCs with a slow processor it might create timing problems if it is much longer as it has to finish before other stuff kicks off.
I am also looking at the algorithm that takes that long, there might be something iffy in there. There is a loop within the loop doing the calculations and that can be a minefield.
Thanks to Russell at al for all the suggestions.
From: Ross Levis
Sent: Monday, July 7, 2014 10:14 PM
To: 'NZ Borland Developers Group - Delphi List'
Subject: Re: [DUG] Saving aray
Shame it’s not 0 to 255. You could then use an array of byte and write them as bytes to a binary file. It would only be 1.5MB in size so very small and I guess take less than a second to load and save.
If you do really need 257 possible values (0-256) then an array of Word is 2 bytes per value and it would be 3MB in size. Still a very small file.
Writing and reading the array may be possible by dumping the RAM direct to file in bulk and loading it back. There will be some way of doing that I believe and it should very fast.
From: delphi-bounces at listserver.123.net.nz [mailto:delphi-bounces at listserver.123.net.nz] On Behalf Of John Bird
Sent: Monday, 7 July 2014 8:35 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Saving aray
I have a program that builds a very large array (over 1,500,000) of integers, and the calculation to fill the array takes quite a while – around 40-50 secs. If there is a quick way to do it, I would save the array to disk if it was faster than recalculating it the next time.
I am guessing that writing the elements to strings and using CSV etc would be quite slow, as it involves quite a lot of processing. I will run a test to see.
Is there any really fast way to save such an array to disk? The numbers range between 0 and 256 if that helps.
--------------------------------------------------------------------------------
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at listserver.123.net.nz with Subject: unsubscribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20140708/9019ee32/attachment-0001.html
More information about the Delphi
mailing list