MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / benchmark_edge_creation_with_relationships

Function benchmark_edge_creation_with_relationships

tests/unit/test_graph.c:145–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145void benchmark_edge_creation_with_relationships() {
146 printf("benchmark_edge_creation_with_relationships\n");
147 double tic[2];
148 int samples = 64;
149 double timings[samples];
150 int outliers = 0;
151 float threshold = 0.002;
152 int edge_count = 1000000 * 1.10;
153 int node_count = 1000000;
154 int relation_count = 3;
155 EdgeDesc connections[edge_count];
156 Node node;
157 Edge edge;
158 Graph *g = Graph_New(GRAPH_DEFAULT_NODE_CAP, GRAPH_DEFAULT_EDGE_CAP);
159 Graph_AcquireWriteLock(g);
160
161 // Introduce relations types.
162 for(int i = 0; i < relation_count; i++) Graph_AddRelationType(g);
163 for(int i = 0; i < node_count; i++) {
164 node = GE_NEW_NODE();
165 Graph_CreateNode(g, &node, NULL, 0);
166 }
167 for(int i = 0; i < samples; i++) {
168 // Describe connections;
169 // Node I is connected to Node I+1,
170 // Connection type is relationships[I%4].
171 for(int j = 0; j < edge_count; j++) {
172 connections[j].srcId = rand() % node_count; // Source node id.
173 connections[j].destId = rand() % node_count; // Destination node id.
174 connections[j].relationId = i % relation_count; // Relation.
175 }
176
177 simple_tic(tic);
178 for(int j = 0; j < edge_count; j++) {
179 Graph_CreateEdge(g, connections[j].srcId, connections[j].destId, connections[j].relationId,
180 &edge);
181 }
182 timings[i] = simple_toc(tic);
183 printf("%d Formed connections, time: %.6f sec\n", edge_count, timings[i]);
184 if(timings[i] > threshold)
185 outliers++;
186 }
187
188 if(outliers > samples * 0.1) {
189 printf("Node creation took too long\n");
190 for(int i = 0; i < samples; i++) {
191 printf("%d Formed connections, time: %.6f sec\n", edge_count, timings[i]);
192 }
193 // assert(false);
194 }
195
196 Graph_ReleaseLock(g);
197 Graph_Free(g);
198}
199
200void benchmark_graph() {
201 benchmark_node_creation_no_labels();

Callers 1

benchmark_graphFunction · 0.85

Calls 9

Graph_NewFunction · 0.85
Graph_AcquireWriteLockFunction · 0.85
Graph_AddRelationTypeFunction · 0.85
Graph_CreateNodeFunction · 0.85
simple_ticFunction · 0.85
Graph_CreateEdgeFunction · 0.85
simple_tocFunction · 0.85
Graph_ReleaseLockFunction · 0.85
Graph_FreeFunction · 0.85

Tested by

no test coverage detected