#1462 closed Feature Request (Completed)
Need speedup FileReadLine() and FileWriteLine() functions
| Reported by: | Suppir | Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Component: | AutoIt |
| Version: | Severity: | None | |
| Keywords: | FileReadLine, FileWriteLine | Cc: |
Description
AutoIt has a real bad (or none?) buffering while writing or reading files line by line.
Look at this code AutoIt code:
#include <Timers.au3>
Global $starttime = _Timer_Init()
Global $OUT = FileOpen("test.txt", 2)
For $x = 1 to 1000000 Step 1
FileWriteLine($OUT, "Some text 1234567890")
Next
MsgBox(0, "", _Timer_Diff($starttime))
And look at this Perl code:
use Benchmark;
open (OU, ">test.txt");
$t0 = new Benchmark;
for (1 .. 1000000){
print OU "Some text 1234567890\n"
}
$t1 = new Benchmark;
$td = timediff($t1, $t0);
print "the code took:",timestr($td),"\n";
<>
Perl writing lines in file 10 times faster
The same with reading files line by line with FileReadLine(). That is because Perl(and Python, Lua, etc) uses smart buffering while writing or reading data from disc.
We really need to improve perfomance of AutoIt in this very-often-used functions!
Attachments (0)
Change History (10)
comment:1 by , 16 years ago
| Version: | 3.3.5.3 |
|---|
comment:2 by , 16 years ago
FileReadLine is buffered btw.
Are you sure this isn't just AutoIt being slower than perl in general and nothing to do with FileWrite?
comment:3 by , 16 years ago
Also, AutoIt will be internally converting the default UTF16 text into ANSI for output which will impact performance (I'm guessing that perl works just in ANSI). Try changing the output text file to UTF16-LE for a format that requires no conversion.
comment:4 by , 16 years ago
I'm sure. I've trying to do a regex' search & replace in text files.
If we put text file in one variable, then AutoIt speed is equal Perl speed.
But if we are working line by line (reading files & writing to file) that AutoIt 10 times slower.
comment:5 by , 16 years ago
I think, the problem in that fact that AutoIt writes to disc each time these functions are being used. While Perl reads/writes to hard disc with portions.
If we use functions FileReadLine(), FileWriteLine() in loop, the speed are extremely slowing down. We could read file in one variable, but it doesn't work with big files, and it doesn't work if we're going to do some tight work with lines.
comment:7 by , 16 years ago
| Resolution: | → Completed |
|---|---|
| Status: | new → closed |
I've rewritten some of the FileWriteLine() code and it's about 40-50% faster than it was. The OS cache is used for caching and that's not something that will be changed. Any speed differences now should just be because perl is probably faster anyway...

Automatic ticket cleanup.