-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rw_lock_bench.ts
42 lines (37 loc) · 980 Bytes
/
rw_lock_bench.ts
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
import { RwLock as RwLock100 } from "jsr:@core/asyncutil@~1.0.0/rw-lock";
import { RwLock } from "./rw_lock.ts";
const length = 1_000;
Deno.bench({
name: "current",
fn: async () => {
const rwLock = new RwLock(0);
await Promise.all(Array.from({ length }).map(() => rwLock.lock(() => {})));
},
group: "RwLock#lock",
baseline: true,
});
Deno.bench({
name: "v1.0.0",
fn: async () => {
const rwLock = new RwLock100(0);
await Promise.all(Array.from({ length }).map(() => rwLock.lock(() => {})));
},
group: "RwLock#lock",
});
Deno.bench({
name: "current",
fn: async () => {
const rwLock = new RwLock(0);
await Promise.all(Array.from({ length }).map(() => rwLock.rlock(() => {})));
},
group: "RwLock#rlock",
baseline: true,
});
Deno.bench({
name: "v1.0.0",
fn: async () => {
const rwLock = new RwLock100(0);
await Promise.all(Array.from({ length }).map(() => rwLock.rlock(() => {})));
},
group: "RwLock#rlock",
});