'Emscripten processing large stdout as ArrayBuffer
I wonder if there is a way to read large stdout output as ArrayBuffer. So far I have discovered two options:
- having defined
module.print(text => ...)which converts the stdout to text which I need to then reencode into bytes - having defined
module.stdout(byte => ...)which recieves only a single byte to process
In case of using module.stdout, when looking into module .js, I can see a loop in place:
write:(stream,buffer,offset,length,pos)=>{
for(var i=0;i<length;i++){
try{output(buffer[offset+i])} // output() here is reference to my module.stdout
catch(e){throw new FS.ErrnoError(29)}
}
which I could change to:
try{output(buffer, offset, length)}
...and so will get what I need inside my module.stdout(). However I would like to avoid doing modifications in this .js file as its being generated by emscripten.
Reading by byte or as a text is suboptimal in my case as it causes unnecessary computation and conversions/loops which slows down the application esp. when dealing with large outputs (GBs).
Do you have any idea how to approach?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
