Script Preparation code:
Tests:
  • 1. Single occurrences: string.replace

  • string.replaceAll

  • string.includes+string.replace

  • string.includes+string.replaceAll

  • 2. Many occurrences: RE1/g.replace

  • RE2/g.replace

  • RE1/g.replaceAll

  • string.replaceAll (many)

  • string.includes+string.replace (many)

  • string.includes+string.replaceAll (many)

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    1. Single occurrences: string.replace
    string.replaceAll
    string.includes+string.replace
    string.includes+string.replaceAll
    2. Many occurrences: RE1/g.replace
    RE2/g.replace
    RE1/g.replaceAll
    string.replaceAll (many)
    string.includes+string.replace (many)
    string.includes+string.replaceAll (many)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
1a) Single occurrences: replace+string 11885498.0 Ops/sec
1b) Single occurrences: replaceAll+string 10339545.0 Ops/sec
1c) Single occurrences: includes+replace 10468160.0 Ops/sec
1d) Single occurrences: includes+replaceAll 10331771.0 Ops/sec
2a) Many occurrences: replace+RE1/g 12804117.0 Ops/sec
2b) Many occurrences: replace+RE2/g 1535069.6 Ops/sec
2c) Many occurrences: replaceAll+RE1/g 2966125.5 Ops/sec
2d) Many occurrences: replaceAll+string 11471794.0 Ops/sec
2e) Many occurrences: includes+replace 11324181.0 Ops/sec
2f) Many occurrences: includes+replaceAll 11322646.0 Ops/sec