-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoublets-benchmark.js
More file actions
119 lines (107 loc) · 2.77 KB
/
doublets-benchmark.js
File metadata and controls
119 lines (107 loc) · 2.77 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// k6 benchmark script for Doublets GraphQL
import { GraphQLBenchmark, queries, randomVariables } from './common.js';
import { group, sleep } from 'k6';
export let options = {
scenarios: {
create_load: {
executor: 'constant-arrival-rate',
rate: 100, // 100 requests per second
timeUnit: '1s',
duration: '30s',
preAllocatedVUs: 10,
maxVUs: 50,
exec: 'createScenario',
},
update_load: {
executor: 'constant-arrival-rate',
rate: 100,
timeUnit: '1s',
duration: '30s',
preAllocatedVUs: 10,
maxVUs: 50,
exec: 'updateScenario',
startTime: '35s',
},
delete_load: {
executor: 'constant-arrival-rate',
rate: 100,
timeUnit: '1s',
duration: '30s',
preAllocatedVUs: 10,
maxVUs: 50,
exec: 'deleteScenario',
startTime: '70s',
},
read_load: {
executor: 'constant-arrival-rate',
rate: 200,
timeUnit: '1s',
duration: '60s',
preAllocatedVUs: 20,
maxVUs: 100,
exec: 'readScenario',
startTime: '105s',
}
},
thresholds: {
http_req_duration: ['p(95)<1000'], // 95% of requests should be below 1s
http_req_failed: ['rate<0.1'], // Error rate should be below 10%
},
};
const doublets = new GraphQLBenchmark('http://localhost:60341/v1/graphql');
export function createScenario() {
group('Create Operations', function() {
// Create point link
doublets.query(queries.createPointLink);
// Create regular link
const vars = randomVariables();
doublets.query(queries.createLink, {
source: vars.source,
target: vars.target
});
});
}
export function updateScenario() {
group('Update Operations', function() {
const vars = randomVariables();
doublets.query(queries.updateLink, {
id: vars.id,
source: vars.source,
target: vars.target
});
});
}
export function deleteScenario() {
group('Delete Operations', function() {
const vars = randomVariables();
doublets.query(queries.deleteLink, { id: vars.id });
});
}
export function readScenario() {
group('Read Operations', function() {
const vars = randomVariables();
// Each All
doublets.query(queries.allLinks, { limit: 10, offset: 0 });
// Each Identity
doublets.query(queries.linkById, { id: vars.id });
// Each Concrete
doublets.query(queries.concreteLinks, {
source: vars.source,
target: vars.target,
limit: 10,
offset: 0
});
// Each Outgoing
doublets.query(queries.outgoingLinks, {
source: vars.source,
limit: 10,
offset: 0
});
// Each Incoming
doublets.query(queries.incomingLinks, {
target: vars.target,
limit: 10,
offset: 0
});
});
}