Foros: 公開討議 (Thread #29170)

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.

Thank you very much.

Regards,
Michael Kuyumcu

Responder al #57014×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

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
Responder al #57014

Responder al #57016×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

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.

Thank you.
Regards,
Responder al #57016

Responder al #57019×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

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.
Responder al #57019

Responder al #57029×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

RE: Reading a long string from a file (2011-04-27 10:00 by SHIRAISHI Kazuo #57074)

New versions improved the input performace of long records in a file.
They use less heap memories.
Responder al #57014

Responder al #57074×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar