Closed ronag closed 2 years ago
Did you try using "createXXHash32()"?
I did some measurements and I didn't see significant performance difference between returning numbers directly from the library and the following code:
const { createXXHash32 } = require("hash-wasm");
const xxhash32 = await createXXHash32();
function doHash(data) {
const arr = xxhash32.init().update(data).digest('binary');
const num = (((arr[0]*256+arr[1])*256+arr[2])*256)+arr[3];
return num;
}
doHash('hello');
It would be nice if we could get a
Number
out of e.g. xxHash. Right now I have to parse the output hex which is rather slow. I'm using the hash to calculate a index into a form of hash map.