Count the number of occurrences in string (v2)

Revision 2 of this benchmark created by witek on


Description

check the number of occurrences of a single number in a string of numbers

larger string.

Preparation HTML

<script>
  var s = "1246828955792151246828989557928955792151246828928955798955792151246828957921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468289557921512468212895579215124682895579215211246828955792151246828955792151224682891215579215";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
regular expression
s.match(/21/g).length;
ready
split
s.split("21").length - 1
ready

Revisions

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