QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: TheGuardHQ on December 03, 2018, 09:02:55 am
-
Hello everybody.
I have a question about the following sample code:
OPEN "c:\temp\kdb053.txt" FOR INPUT AS #1
t# = TIMER
WHILE NOT EOF(1)
LINE INPUT #1, zeile$
WEND
PRINT TIMER - t#
CLOSE
The file "kdb053.txt" has about 100,000 lines.
When I start the program with QuickBasic 7.1, it takes 0.2 seconds.
QB64 takes over 16 seconds for the same program!
Does anyone have any idea where the problem is?
Thanks and good greeting
Christian
-
Open for BINARY access. That's a QB64 feature (in INPUT mode it is slow to maintain legacy behavior of reading the disk a certain way).
BTW, welcome to the forum!
-
Hi FellippeHeitor,
that really helped me a lot - THANKS!
The program now processes the 100,000 lines in 0.49 seconds.
That sounds good at first, but QB71 is still more than twice as fast.
In this small sample program that does not matter. But if I have to read a lot of files very often, you still notice the difference clearly.
Is there still a way to make it faster or is not there any more?
Christian
-
You could read the whole file at once:
But then you'll have to parse it manually for line breaks.
-
Many Thanks!
-
Now I'm curious as to how your old app was twice as fast as QB64 binary reads. How did you read the file in PDS (QB 7.1)? I never tried it, I bought a copy of QuickBASIC (QB45) in 1990 and it was all I needed until QB64 came along.
Pete