prometheus-client-mmap 0.28.0-aarch64-linux → 1.0.0-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -1
- data/README.md +2 -30
- data/ext/fast_mmaped_file_rs/extconf.rb +1 -3
- data/ext/fast_mmaped_file_rs/src/error.rs +8 -0
- data/ext/fast_mmaped_file_rs/src/mmap/inner.rs +38 -23
- data/ext/fast_mmaped_file_rs/src/mmap.rs +71 -8
- data/lib/2.7/fast_mmaped_file_rs.so +0 -0
- data/lib/3.0/fast_mmaped_file_rs.so +0 -0
- data/lib/3.1/fast_mmaped_file_rs.so +0 -0
- data/lib/3.2/fast_mmaped_file_rs.so +0 -0
- data/lib/prometheus/client/configuration.rb +1 -2
- data/lib/prometheus/client/formats/text.rb +1 -12
- data/lib/prometheus/client/helper/mmaped_file.rb +3 -14
- data/lib/prometheus/client/rack/exporter.rb +1 -3
- data/lib/prometheus/client/version.rb +1 -1
- metadata +4 -46
- data/ext/fast_mmaped_file/extconf.rb +0 -30
- data/ext/fast_mmaped_file/fast_mmaped_file.c +0 -122
- data/ext/fast_mmaped_file/file_format.c +0 -5
- data/ext/fast_mmaped_file/file_format.h +0 -11
- data/ext/fast_mmaped_file/file_parsing.c +0 -195
- data/ext/fast_mmaped_file/file_parsing.h +0 -27
- data/ext/fast_mmaped_file/file_reading.c +0 -102
- data/ext/fast_mmaped_file/file_reading.h +0 -30
- data/ext/fast_mmaped_file/globals.h +0 -14
- data/ext/fast_mmaped_file/mmap.c +0 -438
- data/ext/fast_mmaped_file/mmap.h +0 -61
- data/ext/fast_mmaped_file/rendering.c +0 -199
- data/ext/fast_mmaped_file/rendering.h +0 -8
- data/ext/fast_mmaped_file/utils.c +0 -56
- data/ext/fast_mmaped_file/utils.h +0 -22
- data/ext/fast_mmaped_file/value_access.c +0 -242
- data/ext/fast_mmaped_file/value_access.h +0 -15
- data/lib/2.7/fast_mmaped_file.so +0 -0
- data/lib/3.0/fast_mmaped_file.so +0 -0
- data/lib/3.1/fast_mmaped_file.so +0 -0
- data/lib/3.2/fast_mmaped_file.so +0 -0
- data/lib/prometheus/client/helper/loader.rb +0 -44
- data/vendor/c/hashmap/.gitignore +0 -52
- data/vendor/c/hashmap/LICENSE +0 -21
- data/vendor/c/hashmap/README.md +0 -90
- data/vendor/c/hashmap/_config.yml +0 -1
- data/vendor/c/hashmap/src/hashmap.c +0 -692
- data/vendor/c/hashmap/src/hashmap.h +0 -267
- data/vendor/c/hashmap/test/Makefile +0 -22
- data/vendor/c/hashmap/test/hashmap_test.c +0 -608
- data/vendor/c/jsmn/.travis.yml +0 -4
- data/vendor/c/jsmn/LICENSE +0 -20
- data/vendor/c/jsmn/Makefile +0 -41
- data/vendor/c/jsmn/README.md +0 -168
- data/vendor/c/jsmn/example/jsondump.c +0 -126
- data/vendor/c/jsmn/example/simple.c +0 -76
- data/vendor/c/jsmn/jsmn.c +0 -314
- data/vendor/c/jsmn/jsmn.h +0 -76
- data/vendor/c/jsmn/library.json +0 -16
- data/vendor/c/jsmn/test/test.h +0 -27
- data/vendor/c/jsmn/test/tests.c +0 -407
- data/vendor/c/jsmn/test/testutil.h +0 -94
@@ -1,608 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 2016-2017 David Leeds <davidesleeds@gmail.com>
|
3
|
-
*
|
4
|
-
* Hashmap is free software; you can redistribute it and/or modify
|
5
|
-
* it under the terms of the MIT license. See LICENSE for details.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#include <stdio.h>
|
9
|
-
#include <stdlib.h>
|
10
|
-
#include <stdint.h>
|
11
|
-
#include <stdbool.h>
|
12
|
-
#include <string.h>
|
13
|
-
#include <time.h>
|
14
|
-
#include <assert.h>
|
15
|
-
|
16
|
-
#include <hashmap.h>
|
17
|
-
|
18
|
-
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
|
19
|
-
|
20
|
-
#define TEST_NUM_KEYS 196607 /* Results in max load factor */
|
21
|
-
#define TEST_KEY_STR_LEN 32
|
22
|
-
|
23
|
-
void **keys_str_random;
|
24
|
-
void **keys_str_sequential;
|
25
|
-
void **keys_int_random;
|
26
|
-
void **keys_int_sequential;
|
27
|
-
|
28
|
-
struct hashmap str_map;
|
29
|
-
struct hashmap int_map;
|
30
|
-
|
31
|
-
struct test {
|
32
|
-
const char *name;
|
33
|
-
const char *description;
|
34
|
-
bool (*run)(struct hashmap *map, void **keys);
|
35
|
-
bool pre_load;
|
36
|
-
};
|
37
|
-
|
38
|
-
/*
|
39
|
-
* Test type-specific generation macros
|
40
|
-
*/
|
41
|
-
HASHMAP_FUNCS_DECLARE(test, const void, void)
|
42
|
-
HASHMAP_FUNCS_CREATE(test, const void, void)
|
43
|
-
|
44
|
-
|
45
|
-
uint64_t test_time_us(void)
|
46
|
-
{
|
47
|
-
struct timespec now;
|
48
|
-
|
49
|
-
if (clock_gettime(CLOCK_MONOTONIC, &now)) {
|
50
|
-
assert(0);
|
51
|
-
}
|
52
|
-
return ((uint64_t)now.tv_sec) * 1000000 + (uint64_t)(now.tv_nsec / 1000);
|
53
|
-
}
|
54
|
-
|
55
|
-
void **test_keys_alloc(size_t num)
|
56
|
-
{
|
57
|
-
void **keys;
|
58
|
-
|
59
|
-
keys = (void **)calloc(num, sizeof(void *));
|
60
|
-
if (!keys) {
|
61
|
-
printf("malloc failed\n");
|
62
|
-
exit(1);
|
63
|
-
}
|
64
|
-
return keys;
|
65
|
-
}
|
66
|
-
|
67
|
-
void *test_key_alloc_random_str(void)
|
68
|
-
{
|
69
|
-
size_t i;
|
70
|
-
unsigned num;
|
71
|
-
char *key;
|
72
|
-
|
73
|
-
key = (char *)malloc(TEST_KEY_STR_LEN + 1);
|
74
|
-
if (!key) {
|
75
|
-
printf("malloc failed\n");
|
76
|
-
exit(1);
|
77
|
-
}
|
78
|
-
for (i = 0; i < TEST_KEY_STR_LEN; ++i) {
|
79
|
-
num = random();
|
80
|
-
num = (num % 96) + 32; /* ASCII printable only */
|
81
|
-
key[i] = (char)num;
|
82
|
-
}
|
83
|
-
key[TEST_KEY_STR_LEN] = '\0';
|
84
|
-
return key;
|
85
|
-
}
|
86
|
-
void *test_key_alloc_random_int(void)
|
87
|
-
{
|
88
|
-
uint64_t *key;
|
89
|
-
|
90
|
-
key = (uint64_t *)malloc(sizeof(*key));
|
91
|
-
if (!key) {
|
92
|
-
printf("malloc failed\n");
|
93
|
-
exit(1);
|
94
|
-
}
|
95
|
-
/* RAND_MAX is not guaranteed to be more than 32K */
|
96
|
-
*key = (uint64_t)(random() & 0xffff) << 48 |
|
97
|
-
(uint64_t)(random() & 0xffff) << 32 |
|
98
|
-
(uint64_t)(random() & 0xffff) << 16 |
|
99
|
-
(uint64_t)(random() & 0xffff);
|
100
|
-
return key;
|
101
|
-
}
|
102
|
-
|
103
|
-
void *test_key_alloc_sequential_str(size_t index)
|
104
|
-
{
|
105
|
-
char *key;
|
106
|
-
|
107
|
-
key = (char *)malloc(TEST_KEY_STR_LEN + 1);
|
108
|
-
if (!key) {
|
109
|
-
printf("malloc failed\n");
|
110
|
-
exit(1);
|
111
|
-
}
|
112
|
-
snprintf(key, TEST_KEY_STR_LEN + 1, "sequential key! %010zu", index);
|
113
|
-
return key;
|
114
|
-
}
|
115
|
-
|
116
|
-
void *test_key_alloc_sequential_int(size_t index)
|
117
|
-
{
|
118
|
-
uint64_t *key;
|
119
|
-
|
120
|
-
key = (uint64_t *)malloc(sizeof(*key));
|
121
|
-
if (!key) {
|
122
|
-
printf("malloc failed\n");
|
123
|
-
exit(1);
|
124
|
-
}
|
125
|
-
*key = index;
|
126
|
-
return key;
|
127
|
-
}
|
128
|
-
|
129
|
-
void test_keys_generate(void)
|
130
|
-
{
|
131
|
-
size_t i;
|
132
|
-
|
133
|
-
srandom(99); /* Use reproducible random sequences */
|
134
|
-
|
135
|
-
keys_str_random = test_keys_alloc(TEST_NUM_KEYS + 1);
|
136
|
-
keys_str_sequential = test_keys_alloc(TEST_NUM_KEYS + 1);
|
137
|
-
keys_int_random = test_keys_alloc(TEST_NUM_KEYS + 1);
|
138
|
-
keys_int_sequential = test_keys_alloc(TEST_NUM_KEYS + 1);
|
139
|
-
for (i = 0; i < TEST_NUM_KEYS; ++i) {
|
140
|
-
keys_str_random[i] = test_key_alloc_random_str();
|
141
|
-
keys_str_sequential[i] = test_key_alloc_sequential_str(i);
|
142
|
-
keys_int_random[i] = test_key_alloc_random_int();
|
143
|
-
keys_int_sequential[i] = test_key_alloc_sequential_int(i);
|
144
|
-
}
|
145
|
-
keys_str_random[i] = NULL;
|
146
|
-
keys_str_sequential[i] = NULL;
|
147
|
-
keys_int_random[i] = NULL;
|
148
|
-
keys_int_sequential[i] = NULL;
|
149
|
-
}
|
150
|
-
|
151
|
-
void test_load_keys(struct hashmap *map, void **keys)
|
152
|
-
{
|
153
|
-
void **key;
|
154
|
-
|
155
|
-
for (key = keys; *key; ++key) {
|
156
|
-
if (!test_hashmap_put(map, *key, *key)) {
|
157
|
-
printf("hashmap_put() failed");
|
158
|
-
exit(1);
|
159
|
-
}
|
160
|
-
}
|
161
|
-
}
|
162
|
-
|
163
|
-
void test_reset_map(struct hashmap *map)
|
164
|
-
{
|
165
|
-
hashmap_reset(map);
|
166
|
-
}
|
167
|
-
|
168
|
-
void test_print_stats(struct hashmap *map, const char *label)
|
169
|
-
{
|
170
|
-
printf("Hashmap stats: %s\n", label);
|
171
|
-
printf(" # entries: %zu\n", hashmap_size(map));
|
172
|
-
printf(" Table size: %zu\n", map->table_size);
|
173
|
-
printf(" Load factor: %.4f\n", hashmap_load_factor(map));
|
174
|
-
printf(" Collisions mean: %.4f\n", hashmap_collisions_mean(map));
|
175
|
-
printf(" Collisions variance: %.4f\n",
|
176
|
-
hashmap_collisions_variance(map));
|
177
|
-
|
178
|
-
}
|
179
|
-
|
180
|
-
bool test_run(struct hashmap *map, void **keys, const struct test *t)
|
181
|
-
{
|
182
|
-
bool success;
|
183
|
-
uint64_t time_us;
|
184
|
-
|
185
|
-
assert(t != NULL);
|
186
|
-
assert(t->name != NULL);
|
187
|
-
assert(t->run != NULL);
|
188
|
-
|
189
|
-
if (t->pre_load) {
|
190
|
-
printf("Pre-loading keys...");
|
191
|
-
test_load_keys(map, keys);
|
192
|
-
printf("done\n");
|
193
|
-
}
|
194
|
-
printf("Running...\n");
|
195
|
-
time_us = test_time_us();
|
196
|
-
success = t->run(map, keys);
|
197
|
-
time_us = test_time_us() - time_us;
|
198
|
-
if (success) {
|
199
|
-
printf("Completed successfully\n");
|
200
|
-
} else {
|
201
|
-
printf("Failed\n");
|
202
|
-
}
|
203
|
-
printf("Run time: %llu microseconds\n", (long long unsigned)time_us);
|
204
|
-
test_print_stats(map, t->name);
|
205
|
-
test_reset_map(map);
|
206
|
-
return success;
|
207
|
-
}
|
208
|
-
|
209
|
-
bool test_run_all(struct hashmap *map, void **keys,
|
210
|
-
const struct test *tests, size_t num_tests, const char *env)
|
211
|
-
{
|
212
|
-
const struct test *t;
|
213
|
-
size_t num_failed = 0;
|
214
|
-
|
215
|
-
printf("\n**************************************************\n");
|
216
|
-
printf("Starting test series:\n");
|
217
|
-
printf(" %s\n", env);
|
218
|
-
printf("**************************************************\n\n");
|
219
|
-
for (t = tests; t < &tests[num_tests]; ++t) {
|
220
|
-
printf("\n**************************************************"
|
221
|
-
"\n");
|
222
|
-
printf("Test %02u: %s\n", (unsigned)(t - tests) + 1, t->name);
|
223
|
-
if (t->description) {
|
224
|
-
printf(" Description: %s\n", t->description);
|
225
|
-
}
|
226
|
-
printf("\n");
|
227
|
-
if (!test_run(map, keys, t)) {
|
228
|
-
++num_failed;
|
229
|
-
}
|
230
|
-
}
|
231
|
-
printf("\n**************************************************\n");
|
232
|
-
printf("Test results:\n");
|
233
|
-
printf(" Passed: %zu\n", num_tests - num_failed);
|
234
|
-
printf(" Failed: %zu\n", num_failed);
|
235
|
-
printf("**************************************************\n");
|
236
|
-
return (num_failed == 0);
|
237
|
-
}
|
238
|
-
|
239
|
-
size_t test_hash_uint64(const void *key)
|
240
|
-
{
|
241
|
-
const uint8_t *byte = (const uint8_t *)key;
|
242
|
-
uint8_t i;
|
243
|
-
size_t hash = 0;
|
244
|
-
|
245
|
-
for (i = 0; i < sizeof(uint64_t); ++i, ++byte) {
|
246
|
-
hash += *byte;
|
247
|
-
hash += (hash << 10);
|
248
|
-
hash ^= (hash >> 6);
|
249
|
-
}
|
250
|
-
hash += (hash << 3);
|
251
|
-
hash ^= (hash >> 11);
|
252
|
-
hash += (hash << 15);
|
253
|
-
return hash;
|
254
|
-
}
|
255
|
-
|
256
|
-
int test_compare_uint64(const void *a, const void *b)
|
257
|
-
{
|
258
|
-
return *(int64_t *)a - *(int64_t *)b;
|
259
|
-
}
|
260
|
-
|
261
|
-
bool test_put(struct hashmap *map, void **keys)
|
262
|
-
{
|
263
|
-
void **key;
|
264
|
-
void *data;
|
265
|
-
|
266
|
-
for (key = keys; *key; ++key) {
|
267
|
-
data = test_hashmap_put(map, *key, *key);
|
268
|
-
if (!data) {
|
269
|
-
printf("malloc failed\n");
|
270
|
-
exit(1);
|
271
|
-
}
|
272
|
-
if (data != *key) {
|
273
|
-
printf("duplicate key found\n");
|
274
|
-
return false;
|
275
|
-
}
|
276
|
-
}
|
277
|
-
return true;
|
278
|
-
}
|
279
|
-
|
280
|
-
bool test_put_existing(struct hashmap *map, void **keys)
|
281
|
-
{
|
282
|
-
void **key;
|
283
|
-
void *data;
|
284
|
-
int temp_data = 99;
|
285
|
-
|
286
|
-
for (key = keys; *key; ++key) {
|
287
|
-
data = hashmap_put(map, *key, &temp_data);
|
288
|
-
if (!data) {
|
289
|
-
printf("malloc failed\n");
|
290
|
-
exit(1);
|
291
|
-
}
|
292
|
-
if (data != *key) {
|
293
|
-
printf("did not return existing data\n");
|
294
|
-
return false;
|
295
|
-
}
|
296
|
-
}
|
297
|
-
return true;
|
298
|
-
}
|
299
|
-
|
300
|
-
bool test_get(struct hashmap *map, void **keys)
|
301
|
-
{
|
302
|
-
void **key;
|
303
|
-
void *data;
|
304
|
-
|
305
|
-
for (key = keys; *key; ++key) {
|
306
|
-
data = test_hashmap_get(map, *key);
|
307
|
-
if (!data) {
|
308
|
-
printf("entry not found\n");
|
309
|
-
return false;
|
310
|
-
}
|
311
|
-
if (data != *key) {
|
312
|
-
printf("got wrong entry\n");
|
313
|
-
return false;
|
314
|
-
}
|
315
|
-
}
|
316
|
-
return true;
|
317
|
-
}
|
318
|
-
|
319
|
-
bool test_get_nonexisting(struct hashmap *map, void **keys)
|
320
|
-
{
|
321
|
-
void **key;
|
322
|
-
void *data;
|
323
|
-
const char *fake_key = "test_get_nonexisting fake key!";
|
324
|
-
|
325
|
-
for (key = keys; *key; ++key) {
|
326
|
-
data = hashmap_get(map, fake_key);
|
327
|
-
if (data) {
|
328
|
-
printf("unexpected entry found\n");
|
329
|
-
return false;
|
330
|
-
}
|
331
|
-
}
|
332
|
-
return true;
|
333
|
-
}
|
334
|
-
|
335
|
-
bool test_remove(struct hashmap *map, void **keys)
|
336
|
-
{
|
337
|
-
void **key;
|
338
|
-
void *data;
|
339
|
-
|
340
|
-
for (key = keys; *key; ++key) {
|
341
|
-
data = test_hashmap_remove(map, *key);
|
342
|
-
if (!data) {
|
343
|
-
printf("entry not found\n");
|
344
|
-
return false;
|
345
|
-
}
|
346
|
-
if (data != *key) {
|
347
|
-
printf("removed wrong entry\n");
|
348
|
-
return false;
|
349
|
-
}
|
350
|
-
}
|
351
|
-
return true;
|
352
|
-
}
|
353
|
-
|
354
|
-
bool test_put_remove(struct hashmap *map, void **keys)
|
355
|
-
{
|
356
|
-
size_t i = 0;
|
357
|
-
void **key;
|
358
|
-
void *data;
|
359
|
-
|
360
|
-
if (!test_put(map, keys)) {
|
361
|
-
return false;
|
362
|
-
}
|
363
|
-
for (key = keys; *key; ++key) {
|
364
|
-
if (i++ >= TEST_NUM_KEYS / 2) {
|
365
|
-
break;
|
366
|
-
}
|
367
|
-
data = test_hashmap_remove(map, *key);
|
368
|
-
if (!data) {
|
369
|
-
printf("key not found\n");
|
370
|
-
return false;
|
371
|
-
}
|
372
|
-
if (data != *key) {
|
373
|
-
printf("removed wrong entry\n");
|
374
|
-
return false;
|
375
|
-
}
|
376
|
-
}
|
377
|
-
test_print_stats(map, "test_put_remove done");
|
378
|
-
i = 0;
|
379
|
-
for (key = keys; *key; ++key) {
|
380
|
-
if (i++ >= TEST_NUM_KEYS / 2) {
|
381
|
-
break;
|
382
|
-
}
|
383
|
-
data = test_hashmap_put(map, *key, *key);
|
384
|
-
if (!data) {
|
385
|
-
printf("malloc failed\n");
|
386
|
-
exit(1);
|
387
|
-
}
|
388
|
-
if (data != *key) {
|
389
|
-
printf("duplicate key found\n");
|
390
|
-
return false;
|
391
|
-
}
|
392
|
-
}
|
393
|
-
return true;
|
394
|
-
}
|
395
|
-
|
396
|
-
bool test_iterate(struct hashmap *map, void **keys)
|
397
|
-
{
|
398
|
-
size_t i = 0;
|
399
|
-
struct hashmap_iter *iter = hashmap_iter(map);
|
400
|
-
|
401
|
-
for (; iter; iter = hashmap_iter_next(map, iter)) {
|
402
|
-
++i;
|
403
|
-
}
|
404
|
-
if (i != TEST_NUM_KEYS) {
|
405
|
-
printf("did not iterate through all entries: "
|
406
|
-
"observed %zu, expected %u\n", i, TEST_NUM_KEYS);
|
407
|
-
return false;
|
408
|
-
}
|
409
|
-
return true;
|
410
|
-
}
|
411
|
-
|
412
|
-
bool test_iterate_remove(struct hashmap *map, void **keys)
|
413
|
-
{
|
414
|
-
size_t i = 0;
|
415
|
-
struct hashmap_iter *iter = hashmap_iter(map);
|
416
|
-
const void *key;
|
417
|
-
|
418
|
-
while (iter) {
|
419
|
-
++i;
|
420
|
-
key = test_hashmap_iter_get_key(iter);
|
421
|
-
if (test_hashmap_get(map, key) != key) {
|
422
|
-
printf("invalid iterator on entry #%zu\n", i);
|
423
|
-
return false;
|
424
|
-
}
|
425
|
-
iter = hashmap_iter_remove(map, iter);
|
426
|
-
if (test_hashmap_get(map, key) != NULL) {
|
427
|
-
printf("iter_remove failed on entry #%zu\n", i);
|
428
|
-
return false;
|
429
|
-
}
|
430
|
-
}
|
431
|
-
if (i != TEST_NUM_KEYS) {
|
432
|
-
printf("did not iterate through all entries: "
|
433
|
-
"observed %zu, expected %u\n", i, TEST_NUM_KEYS);
|
434
|
-
return false;
|
435
|
-
}
|
436
|
-
return true;
|
437
|
-
}
|
438
|
-
|
439
|
-
struct test_foreach_arg {
|
440
|
-
struct hashmap *map;
|
441
|
-
size_t i;
|
442
|
-
};
|
443
|
-
|
444
|
-
int test_foreach_callback(const void *key, void *data, void *arg)
|
445
|
-
{
|
446
|
-
struct test_foreach_arg *state = (struct test_foreach_arg *)arg;
|
447
|
-
|
448
|
-
if (state->i & 1) {
|
449
|
-
/* Remove every other key */
|
450
|
-
if (!test_hashmap_remove(state->map, key)) {
|
451
|
-
printf("could not remove expected key\n");
|
452
|
-
return -1;
|
453
|
-
}
|
454
|
-
}
|
455
|
-
++state->i;
|
456
|
-
return 0;
|
457
|
-
}
|
458
|
-
|
459
|
-
bool test_foreach(struct hashmap *map, void **keys)
|
460
|
-
{
|
461
|
-
struct test_foreach_arg arg = { map, 1 };
|
462
|
-
size_t size = hashmap_size(map);
|
463
|
-
|
464
|
-
if (test_hashmap_foreach(map, test_foreach_callback, &arg) < 0) {
|
465
|
-
return false;
|
466
|
-
}
|
467
|
-
if (hashmap_size(map) != size / 2) {
|
468
|
-
printf("foreach delete did not remove expected # of entries: "
|
469
|
-
"contains %zu vs. expected %zu\n", hashmap_size(map),
|
470
|
-
size / 2);
|
471
|
-
return false;
|
472
|
-
}
|
473
|
-
return true;
|
474
|
-
}
|
475
|
-
|
476
|
-
bool test_clear(struct hashmap *map, void **keys)
|
477
|
-
{
|
478
|
-
hashmap_clear(map);
|
479
|
-
return true;
|
480
|
-
}
|
481
|
-
|
482
|
-
bool test_reset(struct hashmap *map, void **keys)
|
483
|
-
{
|
484
|
-
hashmap_reset(map);
|
485
|
-
return true;
|
486
|
-
}
|
487
|
-
|
488
|
-
const struct test const tests[] = {
|
489
|
-
{
|
490
|
-
.name = "put performance",
|
491
|
-
.description = "put new hash keys",
|
492
|
-
.run = test_put
|
493
|
-
},
|
494
|
-
{
|
495
|
-
.name = "put existing performance",
|
496
|
-
.description = "attempt to put existing hash keys",
|
497
|
-
.run = test_put_existing,
|
498
|
-
.pre_load = true
|
499
|
-
},
|
500
|
-
{
|
501
|
-
.name = "get existing performance",
|
502
|
-
.description = "get existing hash keys",
|
503
|
-
.run = test_get,
|
504
|
-
.pre_load = true
|
505
|
-
},
|
506
|
-
{
|
507
|
-
.name = "get non-existing performance",
|
508
|
-
.description = "get nonexistent hash keys",
|
509
|
-
.run = test_get_nonexisting,
|
510
|
-
.pre_load = true
|
511
|
-
},
|
512
|
-
{
|
513
|
-
.name = "remove performance",
|
514
|
-
.description = "remove hash keys",
|
515
|
-
.run = test_remove,
|
516
|
-
.pre_load = true
|
517
|
-
},
|
518
|
-
{
|
519
|
-
.name = "mixed put/remove performance",
|
520
|
-
.description = "put, remove 1/2, then put them back",
|
521
|
-
.run = test_put_remove
|
522
|
-
},
|
523
|
-
{
|
524
|
-
.name = "iterate performance",
|
525
|
-
.description = "iterate through entries",
|
526
|
-
.run = test_iterate,
|
527
|
-
.pre_load = true
|
528
|
-
},
|
529
|
-
{
|
530
|
-
.name = "iterate remove all",
|
531
|
-
.description = "iterate and remove all entries",
|
532
|
-
.run = test_iterate_remove,
|
533
|
-
.pre_load = true
|
534
|
-
},
|
535
|
-
{
|
536
|
-
.name = "removal in foreach",
|
537
|
-
.description = "iterate and delete 1/2 using hashmap_foreach",
|
538
|
-
.run = test_foreach,
|
539
|
-
.pre_load = true
|
540
|
-
},
|
541
|
-
{
|
542
|
-
.name = "clear performance",
|
543
|
-
.description = "clear entries",
|
544
|
-
.run = test_clear,
|
545
|
-
.pre_load = true
|
546
|
-
},
|
547
|
-
{
|
548
|
-
.name = "reset performance",
|
549
|
-
.description = "reset entries",
|
550
|
-
.run = test_reset,
|
551
|
-
.pre_load = true
|
552
|
-
}
|
553
|
-
};
|
554
|
-
|
555
|
-
/*
|
556
|
-
* Main function
|
557
|
-
*/
|
558
|
-
int main(int argc, char **argv)
|
559
|
-
{
|
560
|
-
bool success = true;
|
561
|
-
|
562
|
-
/* Initialize */
|
563
|
-
printf("Initializing hash maps...");
|
564
|
-
if (hashmap_init(&str_map, hashmap_hash_string, hashmap_compare_string,
|
565
|
-
0) < 0) {
|
566
|
-
success = false;
|
567
|
-
}
|
568
|
-
/*
|
569
|
-
hashmap_set_key_alloc_funcs(&str_map, hashmap_alloc_key_string, free);
|
570
|
-
*/
|
571
|
-
if (hashmap_init(&int_map, test_hash_uint64, test_compare_uint64,
|
572
|
-
0) < 0) {
|
573
|
-
success = false;
|
574
|
-
}
|
575
|
-
printf("done\n");
|
576
|
-
|
577
|
-
if (!success) {
|
578
|
-
printf("Hashmap init failed");
|
579
|
-
return 1;
|
580
|
-
}
|
581
|
-
|
582
|
-
printf("Generating test %u test keys...", TEST_NUM_KEYS);
|
583
|
-
test_keys_generate();
|
584
|
-
printf("done\n");
|
585
|
-
|
586
|
-
printf("Running tests\n\n");
|
587
|
-
success &= test_run_all(&str_map, keys_str_random, tests,
|
588
|
-
ARRAY_LEN(tests), "Hashmap w/randomized string keys");
|
589
|
-
success &= test_run_all(&str_map, keys_str_sequential, tests,
|
590
|
-
ARRAY_LEN(tests), "Hashmap w/sequential string keys");
|
591
|
-
|
592
|
-
success &= test_run_all(&int_map, keys_int_random, tests,
|
593
|
-
ARRAY_LEN(tests), "Hashmap w/randomized integer keys");
|
594
|
-
|
595
|
-
success &= test_run_all(&int_map, keys_int_sequential, tests,
|
596
|
-
ARRAY_LEN(tests), "Hashmap w/sequential integer keys");
|
597
|
-
|
598
|
-
printf("\nTests finished\n");
|
599
|
-
|
600
|
-
hashmap_destroy(&str_map);
|
601
|
-
hashmap_destroy(&int_map);
|
602
|
-
|
603
|
-
if (!success) {
|
604
|
-
printf("Tests FAILED\n");
|
605
|
-
exit(1);
|
606
|
-
}
|
607
|
-
return 0;
|
608
|
-
}
|
data/vendor/c/jsmn/.travis.yml
DELETED
data/vendor/c/jsmn/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010 Serge A. Zaitsev
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
20
|
-
|
data/vendor/c/jsmn/Makefile
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# You can put your build options here
|
2
|
-
-include config.mk
|
3
|
-
|
4
|
-
all: libjsmn.a
|
5
|
-
|
6
|
-
libjsmn.a: jsmn.o
|
7
|
-
$(AR) rc $@ $^
|
8
|
-
|
9
|
-
%.o: %.c jsmn.h
|
10
|
-
$(CC) -c $(CFLAGS) $< -o $@
|
11
|
-
|
12
|
-
test: test_default test_strict test_links test_strict_links
|
13
|
-
test_default: test/tests.c
|
14
|
-
$(CC) $(CFLAGS) $(LDFLAGS) $< -o test/$@
|
15
|
-
./test/$@
|
16
|
-
test_strict: test/tests.c
|
17
|
-
$(CC) -DJSMN_STRICT=1 $(CFLAGS) $(LDFLAGS) $< -o test/$@
|
18
|
-
./test/$@
|
19
|
-
test_links: test/tests.c
|
20
|
-
$(CC) -DJSMN_PARENT_LINKS=1 $(CFLAGS) $(LDFLAGS) $< -o test/$@
|
21
|
-
./test/$@
|
22
|
-
test_strict_links: test/tests.c
|
23
|
-
$(CC) -DJSMN_STRICT=1 -DJSMN_PARENT_LINKS=1 $(CFLAGS) $(LDFLAGS) $< -o test/$@
|
24
|
-
./test/$@
|
25
|
-
|
26
|
-
jsmn_test.o: jsmn_test.c libjsmn.a
|
27
|
-
|
28
|
-
simple_example: example/simple.o libjsmn.a
|
29
|
-
$(CC) $(LDFLAGS) $^ -o $@
|
30
|
-
|
31
|
-
jsondump: example/jsondump.o libjsmn.a
|
32
|
-
$(CC) $(LDFLAGS) $^ -o $@
|
33
|
-
|
34
|
-
clean:
|
35
|
-
rm -f *.o example/*.o
|
36
|
-
rm -f *.a *.so
|
37
|
-
rm -f simple_example
|
38
|
-
rm -f jsondump
|
39
|
-
|
40
|
-
.PHONY: all clean test
|
41
|
-
|