1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/ext
Marcos Casagrande 7847de0974
perf(ext/event): optimize addEventListener options converter (#20203)
This PR optimizes `addEventListener` by replacing
`webidl.createDictionaryConverter("AddEventListenerOptions", ...)` with
a custom options parsing function to avoid the overhead of `webidl`
methods

**this PR**

```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.1 (x86_64-unknown-linux-gnu)

benchmark                                           time (avg)        iter/s             (min … max)       p75       p99      p995
---------------------------------------------------------------------------------------------------- -----------------------------
addEventListener options converter (undefined)       4.87 ns/iter 205,248,660.8     (4.7 ns … 13.18 ns)   4.91 ns    5.4 ns    5.6 ns
addEventListener options converter (signal)         13.02 ns/iter  76,782,031.2   (11.74 ns … 18.84 ns)  13.08 ns  16.22 ns  16.57 ns
```

**main**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.1 (x86_64-unknown-linux-gnu)

benchmark                                           time (avg)        iter/s             (min … max)       p75       p99      p995
---------------------------------------------------------------------------------------------------- -----------------------------
addEventListener options converter (undefined)     108.36 ns/iter   9,228,688.6  (103.5 ns … 129.88 ns) 109.69 ns 115.61 ns 125.28 ns
addEventListener options converter (signal)        134.03 ns/iter   7,460,878.1 (129.14 ns … 144.54 ns) 135.68 ns 141.13 ns  144.1 ns
```

```js
const tg = new EventTarget();
const signal = new AbortController().signal;

Deno.bench("addEventListener options converter (undefined)", () => {
  tg.addEventListener("foo", null); // null callback to only bench options converter
});

Deno.bench("addEventListener options converter (signal)", () => {
  tg.addEventListener("foo", null, { signal });
});
```

Towards https://github.com/denoland/deno/issues/20167
2023-08-20 11:30:57 +02:00
..
broadcast_channel chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
cache chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
console chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
crypto chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
fetch fix: release ReadeableStream in fetch (#17365) 2023-08-16 14:02:15 +02:00
ffi chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
fs chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
http feat(ext/web): resourceForReadableStream (#20180) 2023-08-17 07:52:37 -06:00
io chore: deno_core -> 0.201.0 (#20135) 2023-08-12 19:04:45 +00:00
kv feat(ext/kv): key expiration (#20091) 2023-08-18 17:34:16 +08:00
napi chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
net fix(ext/net): implement a graceful error on an invalid SSL certificate (#20157) 2023-08-15 00:11:12 +00:00
node fix(node/http): emit error when addr in use (#20200) 2023-08-18 13:48:18 +02:00
tls chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
url perf(ext/urlpattern): optimize URLPattern.exec (#20170) 2023-08-16 12:58:03 +02:00
web perf(ext/event): optimize addEventListener options converter (#20203) 2023-08-20 11:30:57 +02:00
webidl chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
websocket chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
webstorage chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00