Test name | Executions per second |
---|---|
str_en | 6557358.5 Ops/sec |
str_ar | 2509458.5 Ops/sec |
str_en_large | 1376575.0 Ops/sec |
str_ar_large | 516037.7 Ops/sec |
<!--your preparation HTML code goes here-->
const str_en = "Comparing the performance of UTF-8 vs UTF-16 string encoding copying into and out of WASM. 🙂";
const str_ar = "استعار جحا مرة آنية من جاره وعندما أعادها له أعاد معها آنية صغيرة";
const str_en_large = str_en.repeat(10);
const str_ar_large = str_ar.repeat(10);
const encoder = new TextEncoder('utf-8');
const decoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
const buf = encoder.encode(str_en);
const str = decoder.decode(buf);
const buf = encoder.encode(str_ar);
const str = decoder.decode(buf);
const buf = encoder.encode(str_en_large);
const str = decoder.decode(buf);
const buf = encoder.encode(str_ar_large);
const str = decoder.decode(buf);