This repository has been archived by the owner on Apr 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (58 loc) · 1.49 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
var AWS = require("aws-sdk");
AWS.config.update({
region: "us-west-2",
endpoint: "http://localhost:8042",
});
var docClient = new AWS.DynamoDB.DocumentClient();
const workspaceId = 4;
const timesTest = 100;
const query = async () => {
var params = {
TableName: "aggregation_users",
KeyConditionExpression: "#ws = :wsId",
ExpressionAttributeNames: {
"#ws": "workspaceId",
},
ExpressionAttributeValues: {
":wsId": workspaceId,
},
};
var totalQueryResults = 0;
var items;
const startTime = Date.now();
do {
const startQuery = Date.now();
items = await docClient.query(params).promise();
console.log(
`Got: ${items.Items.length} documents with execute time: ${
Date.now() - startQuery
}`
);
totalQueryResults += items.Items.length;
params.ExclusiveStartKey = items.LastEvaluatedKey;
} while (typeof items.LastEvaluatedKey !== "undefined");
const executeTime = Date.now() - startTime;
console.log(
`Got total: ${totalQueryResults} items with execute time: ${executeTime}`
);
return {
count: totalQueryResults,
time: executeTime,
};
};
(async () => {
const results = [];
for (let index = 0; index < timesTest; index++) {
console.log(`Start times ${index}:`);
const res = await query();
results.push(res);
console.log("End\n");
}
console.log(results);
var sum = 0;
results.map((m) => {
sum += m.time;
});
console.log(sum);
console.log(sum / timesTest);
})();