diff options
author | Marcos Casagrande <marcos@denode.com> | 2023-10-06 23:21:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-06 23:21:48 +0200 |
commit | ceecd8c495619284eee5763c1adb4afba345dceb (patch) | |
tree | 098e8cb76c5df08dd006bcda62343d0a02d6a199 /cli/tests/node_compat/test/parallel/test-buffer-arraybuffer.js | |
parent | cba5ae45c2422a4cf9df3a149a646a191a8f27b2 (diff) |
perf(ext/web): optimize structuredClone without transferables (#20730)
This PR optimizes `structuredClone` when it's called without
transferables.
### Benchmarks
**main**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.1 (x86_64-unknown-linux-gnu)
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------------------------- -----------------------------
structuredClone object 1.64 µs/iter 611,086.0 (1.58 µs … 1.84 µs) 1.66 µs 1.84 µs 1.84 µs
structuredClone transferables 2.82 µs/iter 354,281.4 (2.78 µs … 2.92 µs) 2.84 µs 2.92 µs 2.92 µs
```
**this PR**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.1 (x86_64-unknown-linux-gnu)
structuredClone object 1 µs/iter 998,383.5 (971.28 ns … 1.2 µs) 1 µs 1.2 µs 1.2 µs
structuredClone transferables 2.82 µs/iter 355,087.5 (2.7 µs … 3.07 µs) 2.83 µs 3.07 µs 3.07 µs
```
```js
Deno.bench("structuredClone object", () => {
structuredClone({ foo: "bar" });
});
Deno.bench("structuredClone transferables", () => {
const buf = new Uint8Array([97]);
structuredClone(buf, {
transfer: [buf.buffer],
});
});
```
Diffstat (limited to 'cli/tests/node_compat/test/parallel/test-buffer-arraybuffer.js')
0 files changed, 0 insertions, 0 deletions