Test graph creation time.
| 106 | |
| 107 | // Test graph creation time. |
| 108 | void benchmark_node_creation_no_labels() { |
| 109 | printf("benchmark_node_creation_no_labels\n"); |
| 110 | double tic[2]; |
| 111 | int samples = 64; |
| 112 | double timings[samples]; |
| 113 | int outliers = 0; |
| 114 | float threshold = 0.000006; |
| 115 | // size_t n = GRAPH_DEFAULT_NODE_CAP; |
| 116 | Node node; |
| 117 | size_t n = 1000000; |
| 118 | Graph *g = Graph_New(n, n); |
| 119 | Graph_AcquireWriteLock(g); |
| 120 | |
| 121 | for(int i = 0; i < samples; i++) { |
| 122 | // Create N nodes, don't use labels. |
| 123 | simple_tic(tic); |
| 124 | for(int j = 0; j < n; j++) { |
| 125 | node = GE_NEW_NODE(); |
| 126 | Graph_CreateNode(g, &node, NULL, 0); |
| 127 | } |
| 128 | timings[i] = simple_toc(tic); |
| 129 | printf("%zu Nodes created, time: %.6f sec\n", n, timings[i]); |
| 130 | if(timings[i] > threshold) outliers++; |
| 131 | } |
| 132 | |
| 133 | if(outliers > samples * 0.1) { |
| 134 | printf("Node creation took too long\n"); |
| 135 | for(int i = 0; i < samples; i++) { |
| 136 | printf("%zu Nodes created, time: %.6f sec\n", n, timings[i]); |
| 137 | } |
| 138 | // assert(false); |
| 139 | } |
| 140 | |
| 141 | Graph_ReleaseLock(g); |
| 142 | Graph_Free(g); |
| 143 | } |
| 144 | |
| 145 | void benchmark_edge_creation_with_relationships() { |
| 146 | printf("benchmark_edge_creation_with_relationships\n"); |
no test coverage detected