1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00
denoland-deno/ext/fetch
Marcos Casagrande 4e08665973 perf(ext/request): optimize validate and normalize HTTP method (#20143)
This PR optimizes `Request` constructor init method step. It doubles the
speed for known lowercased methods. I also added `PATCH` to known
methods

**this patch**

```
benchmark                   time (avg)        iter/s             (min … max)       p75       p99      p995
---------------------------------------------------------------------------- -----------------------------
method: GET                  1.49 µs/iter     669,336.9     (1.35 µs … 2.02 µs)   1.54 µs   2.02 µs   2.02 µs
method: PATCH                1.85 µs/iter     540,921.5     (1.65 µs … 2.02 µs)   1.91 µs   2.02 µs   2.02 µs
method: get                  1.49 µs/iter     669,067.9     (1.28 µs … 1.69 µs)   1.55 µs   1.69 µs   1.69 µs
```

**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
---------------------------------------------------------------------------- -----------------------------
method: GET                   1.5 µs/iter     665,232.3      (1.3 µs … 2.02 µs)   1.54 µs   2.02 µs   2.02 µs
method: PATCH                2.47 µs/iter     404,052.7     (2.06 µs … 4.05 µs)   2.51 µs   4.05 µs   4.05 µs
method: get                     3 µs/iter     333,277.2     (2.72 µs … 4.04 µs)   3.05 µs   4.04 µs   4.04 µs
```

```js
Deno.bench("method: GET", () => {
  const r = new Request("https://deno.land", {
    method: "GET",
  });
});

Deno.bench("method: PATCH", () => {
  const r = new Request("https://deno.land", {
    method: "PATCH",
    body: '{"foo": "bar"}',
  });
});

Deno.bench("method: get", () => {
  const r = new Request("https://deno.land", {
    method: "get",
  });
});
```
2023-08-21 18:23:27 +05:30
..
20_headers.js perf(ext/headers): use regex.test instead of .exec (#20125) 2023-08-21 18:23:27 +05:30
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 perf(ext/request): optimize validate and normalize HTTP method (#20143) 2023-08-21 18:23:27 +05:30
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 1.36.1 (#20221) 2023-08-21 18:08:38 +05:30
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/