haxe
haxe copied to clipboard
[jvm] sys.io.File.read is a huge performance trap
import haxe.io.Input;
import haxe.io.BytesInput;
function main() {
var input:Input = sys.io.File.read("eval.zip");
// input = new BytesInput(input.readAll()); // that line
try {
var zip = haxe.zip.Reader.readZip(input);
trace("Read");
} catch (e:Dynamic) {
trace(e);
}
input.close();
}
| target | without that line | with |
|---|---|---|
| JVM | 8.101 | 0.637 |
| Eval | 7.781 | 8.454 |
| HL | 2.463 | 1.952 |
| C++ | 5.486 | 2.879 |
I don't know if this is how real Java devs handle this, but it's faster for me.
I reverted that change because the interaction between the buffer and the random access doesn't work the way I thought it would, which breaks all tell() offsets.
Surely there must be a straightforward fix for this...