joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.84k stars 784 forks source link

writeFile - advice on large strings? #562

Open cristianoccazinsp opened 4 years ago

cristianoccazinsp commented 4 years ago

Hello all,

I've noticed that fs.writeFile is about 4 times slower than fs.readFile when using strings and utf8 encoding. After some debugging, it seems that the bottleneck comes from the RN bridge (added timers on native and the actual write operation is very fast).

I'm reading/writing the same amount of data, so I wonder what's causing such a timing difference between read and write if the bottleneck is the RN bridge.

Lastly, is there a better approach to write a big string to disk? I'm trying to write a JSON object to a file so the source is JS. I don't think there's a way to bypass the bridge for such write/read.

Thanks.

jzxchiang1 commented 3 years ago

I'm having the same issue. Super super slow writeFile for a 5 MiB file... (1 minute)