-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
39 lines (33 loc) · 808 Bytes
/
test.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
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({
level: "info",
message: "This is an informational message",
timestamp: "2022-03-01T12:00:00Z",
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow",
};
const startTime = Date.now();
const fetchLog = async (id) => {
try {
const response = await fetch(
`http://127.0.0.1:3000/add/log/${id}`,
requestOptions,
);
console.log(id);
} catch (error) {
console.error(`ID: ${id}, Error: ${error}`);
}
};
const runTests = async () => {
for (let id = 0; id <= 1000000; id++) {
await fetchLog(id);
}
const endTime = Date.now();
console.log(`Time taken: ${endTime - startTime} ms`);
};
runTests();