logger pretify performance

Benchmark created on


Setup

const lines = [
  "warn: this was a mistake, Luke",
  'error: an error occurred while looking up for you dad. The error was: {\n"key":\n"not found",\n"value": "I could not find your dad"\n}\n'
];

Test runner

Ready to run.

Testing in
TestOps/sec
use replace
lines.forEach(line => line.replace(/(\r\n|\n|\r)/gm, ' ').replace(/[ ][ ]*/gm, ' '));
ready
use split and join
lines.forEach(line => line.split(/\r\n|\n|\r|[ ]{2,}/g).join(' '));
ready

Revisions

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