-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
benchmark.ts
45 lines (43 loc) · 1008 Bytes
/
benchmark.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
43
44
45
import Benchmark from "benchmark";
import { join, pathcat } from "./src/index.ts";
const suite = new Benchmark.Suite();
suite
.add("pathcat() With a base URL", () => {
pathcat("https://example.com", "/users/:user_id/posts/:post_id/reactions", {
user_id: 1,
post_id: 2,
limit: 10,
skip: 10,
});
})
.add("pathcat() With no base URL", () => {
pathcat("/users/:user_id/posts/:post_id/reactions", {
user_id: 1,
post_id: 2,
limit: 10,
skip: 10,
});
})
.add("pathcat() With a base URL, and no params", () => {
// @ts-expect-error
pathcat("https://example.com", "/users/:user_id/posts/:post_id/reactions");
})
.add("join() with 2 arguments", () => {
join("https://example.com", "test");
})
.add("join() with many arguments", () => {
join(
"https://example.com",
"test",
"///test",
"//test",
"test",
"/test",
"test",
"/123124124/123"
);
})
.on("cycle", (event: Event) => {
console.log(String(event.target));
})
.run({ async: true });