blueboat icon indicating copy to clipboard operation
blueboat copied to clipboard

Analyze JS<->Rust call performance

Open losfair opened this issue 3 years ago • 0 comments

I was benchmarking some of the crypto routines in Blueboat.

The code is:

const start = Date.now();
const n = 10000;
const key = crypto.getRandomValues(new Uint8Array(16));
const nonce = crypto.getRandomValues(new Uint8Array(12));
const data = crypto.getRandomValues(new Uint8Array(32));

for (let i = 0; i < n; i++) {
  NativeCrypto.AEAD.aes128GcmSivEncrypt({
    key,
    nonce,
    data,
  });
}
const end = Date.now();
return mkJsonResponse({
  duration: end - start,
  n,
  dataLen: data.length,
});

And... it seems that most of the time is spent in the host call itself (instead of the actual encryption):

{"duration":55,"n":10000,"dataLen":320}
{"duration":38,"n":10000,"dataLen":32}

losfair avatar Jan 05 '22 17:01 losfair