Script Preparation code:
AخA
 
var str = '1873189741874817';
Tests:
  • Regex

     
    /^[0-9]{1,20}$/.test(str);
  • Split and Join

     
    str.length < 20 && str.split('').every(x => !isNaN(x));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Regex
    Split and Join

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Linux; Android 10; RMX1911) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.85 Mobile Safari/537.36
Chrome Mobile 94 on Android
View result in a separate tab
Test name Executions per second
Regex 1992390.5 Ops/sec
Split and Join 111243.1 Ops/sec