• Welcome to Valhalla Legends Archive.
 

two files loaded into one array

Started by o.OV, July 27, 2004, 06:00 AM

Previous topic - Next topic

o.OV

Currently I load a single file into a byte array using the code below.


Open "Data1.txt" For Binary Access Read As #69
   ReDim DataBase(LOF(69) - 1)
   Get #69, , DataBase()
Close #69


Now my objective is to append/load ANOTHER Data file to the array.

1. I want to avoid loops. (speed conscious)
2. I want to avoid using a secondary array. (the files are large)

Any ideas? Thanks in advance.
If the facts don't fit the theory, change the facts. - Albert Einstein

Tuberload

If you are really trying to be speed conscious, bypassing loops is not your solution. The solution would be to either use Random access to the file, or bypass VB and look into some disk IO API's. ReadFile, CreateFile, CloseHandle, SetFilePointer, might be something worth looking into.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

o.OV

Quote from: Tuberload on July 27, 2004, 03:26 PM
If you are really trying to be speed conscious, bypassing loops is not your solution. The solution would be to either use Random access to the file, or bypass VB and look into some disk IO API's. ReadFile, CreateFile, CloseHandle, SetFilePointer, might be something worth looking into.

I don't see how using Random access would help..
and I forgot all about APIs.
I already took a look at the ReadFile declaration and it looks promising.
Thanks.
If the facts don't fit the theory, change the facts. - Albert Einstein

Tuberload

Quote from: o.OV on July 27, 2004, 10:35 PMI don't see how using Random access would help..
Have you tested it? I did a test when I started helping Trust[e1] create his bots database and it was significantly faster than using Binary.

Quoteand I forgot all about APIs.
I already took a look at the ReadFile declaration and it looks promising.
Thanks.
Yes it is very promising. Hope it helps.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

o.OV

Quote from: Tuberload on July 28, 2004, 01:35 PM
Quote from: o.OV on July 27, 2004, 10:35 PMI don't see how using Random access would help..
Have you tested it? I did a test when I started helping Trust[e1] create his bots database and it was significantly faster than using Binary.

Did you load the database into memory or did you read a block at a time?
If the facts don't fit the theory, change the facts. - Albert Einstein

Tuberload

Quote from: o.OV on July 28, 2004, 10:48 PMDid you load the database into memory or did you read a block at a time?

The testing only involved loading an entire file into memory using Binary access, Random access, and the API calls.

A roughly 4.5 mb file took:
-> Binary: 18967ms to read into memory
-> Random: 751ms
-> API: 321ms
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

Eli_1

Wow, that's a huge difference.  :-\