test

Benchmark created on


Setup

const input = [
"Group::AB::C::Leaf",
"Group::AB::C",
"Group::AB",
"Group"
];

const expression = /(.*)::([^:]+)$/;

Test runner

Ready to run.

Testing in
TestOps/sec
string manipulation
input.forEach((name) => {
	  const findlastIndex = name.lastIndexOf('::');
  const leaf = findlastIndex !== -1 && name.substr(findlastIndex + 2);

const path = leaf && name.slice(0, findlastIndex);
});
ready
regex

input.forEach((name) => {
  const match = name.match(expression);
  const leaf = match && match[2];
  const path = match && match[1];
});
ready

Revisions

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