Reading a long string from a file (2011-04-24 07:36 by ukimiku #57014)
Dear SHIRAISH Kazuo,
I tried reading a long string (320 000 000 characters) into a string variable using the following code (OPTION CHARACTER BYTE, #1 is open for reading):
INPUT #1: eu$
The program executes correctly, but it takes roughly 40 minutes to do so. There is no time difference for interpreted or compiled versions of Decimal Basic, although the compiled version crashes after reading the string into memory, while the interpreter keeps on executing the follwing code. In the Windows task manager, I can see how much memory is being allocated in both environments, so this seems to be correct.
Anyhow, apart from the crashing, how could I speed up the reading of strings from files into memory? The computer has enough physical memory to hold several strings of that length, but with 40 minutes for each run, testing the program becomes very difficult.
RE: Reading a long string from a file (2011-04-24 09:30 by SHIRAISHI Kazuo #57016)
The following method may increase the performance in some case.
OPTION CHARACTER byte
LET t0=TIME
OPEN #1:NAME "C:\Windows\WindowsUpdate.log"
ASK #1: FILESIZE n
LET s$=REPEAT$(CHR$(0),n)
FOR i=1 TO n
CHARACTER INPUT #1:s$(i:i)
NEXT i
CLOSE #1
PRINT TIME-t0
PRINT s$
END
RE: Reading a long string from a file (2011-04-24 16:11 by ukimiku #57019)
Thanks, I will try.
Why would the compiled version crash? Must I increase memory? Where can I do that for strings? I read they are stored on the system heap, but I find no option to increase that heap or to make Decimal Basic store strings in another location.
RE: Reading a long string from a file (2011-04-25 08:03 by SHIRAISHI Kazuo #57029)
Compiled version uses different heap manager from that of Decimal BASIC, because of those of Delphi and FPC are different. This may be the reason why it crashes, but I do not know the true reason.
In BASICAcc, to decrease the load to the heap manager, decrease both System Stack and Virtual Stack in SetUp Option.