diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 11:19:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:53:24 +0000 |
commit | b5f8ee61a7f7e9bd291dd26b0585d03eb686c941 (patch) | |
tree | d4d31289c39fc00da064a825df13a0b98ce95b10 /web/server/h2o/libh2o/deps/klib/test/kvec_test.cc | |
parent | Adding upstream version 1.44.3. (diff) | |
download | netdata-b5f8ee61a7f7e9bd291dd26b0585d03eb686c941.tar.xz netdata-b5f8ee61a7f7e9bd291dd26b0585d03eb686c941.zip |
Adding upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | web/server/h2o/libh2o/deps/klib/test/kvec_test.cc | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/web/server/h2o/libh2o/deps/klib/test/kvec_test.cc b/web/server/h2o/libh2o/deps/klib/test/kvec_test.cc deleted file mode 100644 index 1015574e4..000000000 --- a/web/server/h2o/libh2o/deps/klib/test/kvec_test.cc +++ /dev/null @@ -1,69 +0,0 @@ -#include <vector> -#include <time.h> -#include <stdio.h> -#include <stdlib.h> -#include "kvec.h" - -int main() -{ - int M = 10, N = 20000000, i, j; - clock_t t; - t = clock(); - for (i = 0; i < M; ++i) { - int *array = (int*)malloc(N * sizeof(int)); - for (j = 0; j < N; ++j) array[j] = j; - free(array); - } - printf("C array, preallocated: %.3f sec\n", - (float)(clock() - t) / CLOCKS_PER_SEC); - t = clock(); - for (i = 0; i < M; ++i) { - int *array = 0, max = 0; - for (j = 0; j < N; ++j) { - if (j == max) { - max = !max? 1 : max << 1; - array = (int*)realloc(array, sizeof(int)*max); - } - array[j] = j; - } - free(array); - } - printf("C array, dynamic: %.3f sec\n", - (float)(clock() - t) / CLOCKS_PER_SEC); - t = clock(); - for (i = 0; i < M; ++i) { - kvec_t(int) array; - kv_init(array); - kv_resize(int, array, N); - for (j = 0; j < N; ++j) kv_a(int, array, j) = j; - kv_destroy(array); - } - printf("C vector, dynamic(kv_a): %.3f sec\n", - (float)(clock() - t) / CLOCKS_PER_SEC); - t = clock(); - for (i = 0; i < M; ++i) { - kvec_t(int) array; - kv_init(array); - for (j = 0; j < N; ++j) - kv_push(int, array, j); - kv_destroy(array); - } - printf("C vector, dynamic(kv_push): %.3f sec\n", - (float)(clock() - t) / CLOCKS_PER_SEC); - t = clock(); - for (i = 0; i < M; ++i) { - std::vector<int> array; - array.reserve(N); - for (j = 0; j < N; ++j) array[j] = j; - } - printf("C++ vector, preallocated: %.3f sec\n", - (float)(clock() - t) / CLOCKS_PER_SEC); - t = clock(); - for (i = 0; i < M; ++i) { - std::vector<int> array; - for (j = 0; j < N; ++j) array.push_back(j); - } - printf("C++ vector, dynamic: %.3f sec\n", - (float)(clock() - t) / CLOCKS_PER_SEC); - return 0; -} |