TextEncoder creation vs reuse

Benchmark created on


Description

difference between a preinitialized reusable text encoder vs initialization every time

Setup

let preInit = new TextEncoder();
let str = "Having 😀 with 💻 and 🚀";

Test runner

Ready to run.

Testing in
TestOps/sec
TextEncoder initialize every time
new TextEncoder().encode(str);
ready
use preinitialized TextEncoder
preInit.encode(str);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.