While creating unit tests for AceBase, I had to compare whether stored binary data equals the generated data, which is 5MB large. The expect comparison method is very slow on this value, takes about 5 seconds:
// Generate data
let data = new Uint8Array(5 * 1000 * 1000);
for(let i = 0 ; i < data.length; i++) { data[i] = i % 255; }
// .. Store in the database & retrieve it again into variable 'stored'
expect(stored).toEqual(data); // <-- SLOW
If I compare the data myself with a loop, this is way faster (takes few ms):
let isEqual = true;
for(let i = 0; i < data.length && isEqual; i++) {
isEqual = data[i] === stored[i];
}
expect(isEqual).toBeTrue();
EDIT: I'm using jasmine v3.7.0, jasmine-core v3.7.1
While creating unit tests for AceBase, I had to compare whether stored binary data equals the generated data, which is 5MB large. The
expectcomparison method is very slow on this value, takes about 5 seconds:If I compare the data myself with a loop, this is way faster (takes few ms):
EDIT: I'm using jasmine v3.7.0, jasmine-core v3.7.1