I am trying to read a file from the bundle assets on Android, and I noticed that it's taking a lot of time. The assets are XOR-encrypted PDF files (if anyone wants, I'm happy to provide them).
I cobbled together a bit of a benchmark using react-native-fetch-blob@0.10.8
:
import RNFetchBlob from "react-native-fetch-blob";
const { fs } = RNFetchBlob;
const t1 = performance.now();
fs.readFile(
fs.asset("bundle-assets://" + filename),
"ascii"
).then(data => {
console.log(performance.now() - t1);
});
I ran this on a Nexus 5 running a development build of the app. All the tests were run while an <ActivityIndicator />
was running in the foreground. Results are in milliseconds, as returned by performance.now()
:
size time (ms)
9.7 MB crash and burn
4 MB 144132.19999999274
3.2 MB 115553.40000000433
1.6 MB 59854.999999995925
781 KB 28170.59999999765
78 KB 3373.600000006263
What could cause react-native-fetch-blob
to take so much time?
Related github issue