deno.land / x / deno@v1.28.2 / cli / bench / cache_api.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
const cacheName = "cache-v1";const cache = await caches.open(cacheName);const req = "https://deno.com";
Deno.bench( `cache_storage_open`, async () => { await caches.open("cache-v2"); },);
Deno.bench( `cache_storage_has`, async () => { await caches.has("cache-v2"); },);
Deno.bench( `cache_storage_delete`, async () => { await caches.delete("cache-v2"); },);
// 100 bytes.const loremIpsum = `Lorem ipsum dolor sit amet, consectetur adipiscing…es ligula in libero. Sed dignissim lacinia nunc. `;let body;for (let index = 1; index <= 110; index++) { body += loremIpsum;}
Deno.bench( `cache_put_body_${Math.floor(body.length / 1024)}_KiB`, async () => { await cache.put(req, new Response(body)); },);
Deno.bench("cache_put_no_body", async () => { await cache.put( "https://deno.land/redirect", Response.redirect("https://deno.com"), );});
Deno.bench("cache_match", async () => { await cache.match(req);});
Deno.bench("cache_delete", async () => { await cache.delete(req);});
deno

Version Info

Tagged at
a year ago