SUZUKI Sosuke
92f105dbe1
Add microbench for String#includes (#25699)
note: This is due to constant folding by the JIT. For `String#includes`
on dynamic strings, the performance improvement is not this significant.
**before:**
```
$ bun ./bench/snippets/string-includes.mjs
cpu: Apple M4 Max
runtime: bun 1.3.5 (arm64-darwin)
benchmark time (avg) (min … max) p75 p99 p999
----------------------------------------------------------------------------- -----------------------------
String.includes - short, hit (middle) 82.24 ns/iter (14.95 ns … 881 ns) 84.98 ns 470 ns 791 ns
String.includes - short, hit (start) 37.44 ns/iter (8.46 ns … 774 ns) 26.08 ns 379 ns 598 ns
String.includes - short, hit (end) 97.27 ns/iter (16.93 ns … 823 ns) 107 ns 537 ns 801 ns
String.includes - short, miss 102 ns/iter (0 ps … 1'598 µs) 42 ns 125 ns 167 ns
String.includes - long, hit (middle) 16.01 ns/iter (14.34 ns … 115 ns) 16.03 ns 20.1 ns 53.1 ns
String.includes - long, miss 945 ns/iter (935 ns … 972 ns) 948 ns 960 ns 972 ns
String.includes - with position 9.83 ns/iter (8.44 ns … 58.45 ns) 9.83 ns 12.31 ns 15.69 ns
```
**after:**
```
$ ./build/release/bun bench/snippets/string-includes.mjs
cpu: Apple M4 Max
runtime: bun 1.3.6 (arm64-darwin)
benchmark time (avg) (min … max) p75 p99 p999
----------------------------------------------------------------------------- -----------------------------
String.includes - short, hit (middle) 243 ps/iter (203 ps … 10.13 ns) 244 ps 325 ps 509 ps !
String.includes - short, hit (start) 374 ps/iter (244 ps … 19.78 ns) 387 ps 488 ps 691 ps
String.includes - short, hit (end) 708 ps/iter (407 ps … 18.03 ns) 651 ps 2.62 ns 2.69 ns
String.includes - short, miss 1.49 ns/iter (407 ps … 27.93 ns) 2.87 ns 3.09 ns 3.78 ns
String.includes - long, hit (middle) 3.28 ns/iter (3.05 ns … 118 ns) 3.15 ns 8.75 ns 16.07 ns
String.includes - long, miss 7.28 ns/iter (3.44 ns … 698 ns) 9.34 ns 42.85 ns 240 ns
String.includes - with position 7.97 ns/iter (3.7 ns … 602 ns) 9.68 ns 52.19 ns 286 ns
```
2025-12-26 21:49:00 -08:00
..
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-02-07 15:13:21 -08:00
2024-11-08 23:15:24 -08:00
2025-02-18 13:12:03 -08:00
2023-03-02 19:02:10 -08:00
2024-11-08 23:15:24 -08:00
2025-02-12 23:37:36 -08:00
2024-12-31 19:48:33 -08:00
2023-03-02 19:02:10 -08:00
2024-11-08 23:15:24 -08:00
2025-11-20 17:14:37 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2023-08-31 17:33:08 -07:00
2024-11-08 23:15:24 -08:00
2025-09-01 02:56:59 -07:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-02-16 00:42:05 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-07-10 00:10:43 -07:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-03-10 20:19:29 -07:00
2025-03-10 20:19:29 -07:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-06-03 03:34:35 -07:00
2024-11-08 23:15:24 -08:00
2022-12-06 14:18:25 -08:00
2022-12-06 14:18:25 -08:00
2023-11-06 03:51:49 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-01-03 13:57:46 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-08-01 14:35:04 -07:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-12-24 19:55:44 -08:00
2024-11-08 23:15:24 -08:00
2025-02-12 23:14:02 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-12-23 22:53:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-04-08 03:57:35 -07:00
2024-09-03 21:32:52 -07:00
2025-04-11 20:59:38 -07:00
2024-11-08 23:15:24 -08:00
2025-11-04 11:56:33 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2023-07-30 23:51:43 -07:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-09-03 21:32:52 -07:00
2024-09-03 21:32:52 -07:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-09-03 21:32:52 -07:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-07-07 23:08:12 -07:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-12-26 21:49:00 -08:00
2024-11-08 23:15:24 -08:00
2025-08-14 22:42:05 -07:00
2024-11-08 23:15:24 -08:00
2024-09-03 21:32:52 -07:00
2023-01-04 18:55:16 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2025-11-28 00:04:30 -08:00
2025-01-08 07:12:18 +00:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-11-08 23:15:24 -08:00
2024-12-24 04:20:24 -08:00