1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/ext/fetch
Marcos Casagrande 2d3d0a579d
perf(ext/headers): optimize getHeader using for loop (#20115)
This PR optimizes the `getHeader` function by replacing `.filter` and
`.map` with a `for` loop

**this patch**

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

benchmark        time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------- -----------------------------
Headers.get      132.2 ns/iter   7,564,093.4 (125.81 ns … 147.66 ns) 133.79 ns 144.92 ns 145.36 ns
```

**main**

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

benchmark        time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------- -----------------------------
Headers.get     191.48 ns/iter   5,222,523.6 (182.75 ns … 212.22 ns)  193.5 ns 205.96 ns 211.51 ns
```

```js

const headers = new Headers({
  "Content-Type": "application/json",
  "Date": "Thu, 10 Aug 2023 07:45:10 GMT",
  "X-Deno": "Deno",
  "Powered-By": "Deno",
  "Content-Encoding": "gzip",
  "Set-Cookie": "__Secure-ID=123; Secure; Domain=example.com",
  "Content-Length": "150",
  "Vary": "Accept-Encoding, Accept, X-Requested-With",
});

Deno.bench("Headers.get", () => {
  const i = headers.get("x-deno");
});
```
2023-08-10 19:41:09 +02:00
..
20_headers.js perf(ext/headers): optimize getHeader using for loop (#20115) 2023-08-10 19:41:09 +02:00
21_formdata.js chore: update deno_lint to 0.46.0 (#19372) 2023-06-05 15:57:01 -04:00
22_body.js chore: update deno_lint to 0.46.0 (#19372) 2023-06-05 15:57:01 -04:00
22_http_client.js refactor: Use ES modules for internal runtime code (#17648) 2023-02-07 20:22:46 +01:00
23_request.js fix(Deno.serve): accessing .url on cloned request throws (#19869) 2023-07-30 09:13:28 -04:00
23_response.js perf: optimize RegExp usage in JS (#19364) 2023-06-05 10:52:40 +02:00
26_fetch.js refactor(ext/fetch): refactor fetch to use new write_error method (#20029) 2023-08-03 14:27:25 -06:00
Cargo.toml chore: forward v1.36.1 to main (#20119) 2023-08-10 16:44:41 +03:00
fs_fetch_handler.rs refactor(ext/fetch): Remove FetchRequestBodyResource from FetchHandler interface (#20100) 2023-08-09 10:47:47 -06:00
internal.d.ts refactor: remove remaining references to "flash" server (#18580) 2023-04-04 12:37:56 +02:00
lib.deno_fetch.d.ts fix(dts): make globals available on globalThis (#19438) 2023-07-03 14:36:55 -04:00
lib.rs refactor(ext/fetch): Remove FetchRequestBodyResource from FetchHandler interface (#20100) 2023-08-09 10:47:47 -06:00
README.md Rename extensions/ directory to ext/ (#11643) 2021-08-11 12:27:05 +02:00

deno_fetch

This crate implements the Fetch API.

Spec: https://fetch.spec.whatwg.org/