[Webkit-unassigned] [Bug 244754] New: String prototype functions are slower in JSC than V8
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Sep 2 20:17:59 PDT 2022
https://bugs.webkit.org/show_bug.cgi?id=244754
Bug ID: 244754
Summary: String prototype functions are slower in JSC than V8
Product: WebKit
Version: WebKit Nightly Build
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
Assignee: webkit-unassigned at lists.webkit.org
Reporter: jarred at jarredsumner.com
❯ jsc foo.mjs
cpu: unknown
runtime: unknown (unknown)
benchmark time (avg) (min … max) p75 p99 p995
----------------------------------------------------------------------------------- -----------------------------
startsWith 11 ns/iter (10.51 ns … 21.54 ns) 10.78 ns 15.12 ns 15.71 ns
prototype_startsWith 34.36 ns/iter (32.08 ns … 150.64 ns) 34.63 ns 39.24 ns 80.12 ns
_startsWith 38.76 ns/iter (36.85 ns … 124.11 ns) 39.07 ns 47.63 ns 81.98 ns
substring(0,8) 36.64 ns/iter (34.45 ns … 148.93 ns) 37.06 ns 45.9 ns 74.68 ns
substring(0, length) === (substr strict) 38.45 ns/iter (36.84 ns … 155.19 ns) 38.82 ns 47.86 ns 75.75 ns
substring(0, length) == (substr non-strict) 38.76 ns/iter (36.8 ns … 130.45 ns) 39.1 ns 47.66 ns 69.83 ns
indexOf strict 15.75 ns/iter (15.49 ns … 24.07 ns) 15.55 ns 17.25 ns 17.47 ns
indexOf non-strict 13.67 ns/iter (13 ns … 18.34 ns) 14.52 ns 17.06 ns 17.14 ns
❯ node foo.mjs
cpu: Apple M1 Max
runtime: node v18.4.0 (arm64-darwin)
benchmark time (avg) (min … max) p75 p99 p995
----------------------------------------------------------------------------------- -----------------------------
startsWith 19.11 ns/iter (18.58 ns … 404.22 ns) 18.68 ns 23.09 ns 26.93 ns
prototype_startsWith 16.19 ns/iter (14.25 ns … 28.51 ns) 17.43 ns 23.3 ns 24.11 ns
_startsWith 16.14 ns/iter (14.55 ns … 285.63 ns) 16.8 ns 21.92 ns 22.95 ns
substring(0,8) 15.94 ns/iter (14.25 ns … 48.39 ns) 16.06 ns 25.28 ns 28.27 ns
substring(0, length) === (substr strict) 15.34 ns/iter (14.25 ns … 31.48 ns) 15.72 ns 22.83 ns 24.01 ns
substring(0, length) == (substr non-strict) 15.87 ns/iter (14.25 ns … 31.93 ns) 15.82 ns 24.57 ns 25.63 ns
indexOf strict 14.68 ns/iter (13.88 ns … 21.2 ns) 14.8 ns 16.66 ns 16.98 ns
indexOf non-strict 14.62 ns/iter (14.29 ns … 18.91 ns) 14.46 ns 16.8 ns 17.02 ns
Code:
```
import { run, bench, baseline } from "./node_modules/mitata/src/cli.mjs";
function _startsWith(str, find) {
return str.substring(0,find.length) === find
}
String.prototype._startsWith = function (find) {
return this.substring(0,find.length) === find
}
baseline("startsWith", () => "/assets/omfg".startsWith('/assets/'));
baseline("prototype_startsWith", () => "/assets/omfg"._startsWith('/assets/'));
baseline("_startsWith", () => _startsWith("/assets/omfg", '/assets/'));
baseline("substring(0,8)", () => "/assets/omfg".substring(0,8) === '/assets/');
baseline("substring(0, length) === (substr strict)", () => "/assets/omfg".substring(0,'/assets/'.length) === '/assets/');
baseline("substring(0, length) == (substr non-strict)", () => "/assets/omfg".substring(0,'/assets/'.length) == '/assets/');
baseline("indexOf strict", () => "/assets/omfg".indexOf('/assets/') === 0);
baseline("indexOf non-strict", () => "/assets/omfg".indexOf('/assets/') == 0);
await run();
```
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220903/9590ff3d/attachment-0001.htm>
More information about the webkit-unassigned
mailing list