summaryrefslogtreecommitdiff
path: root/test/profiling
diff options
context:
space:
mode:
authorchenzizhan <[email protected]>2023-07-18 16:59:25 +0800
committerchenzizhan <[email protected]>2023-07-18 16:59:25 +0800
commit3e3512b4900c1dfd7450cea88b8fc95a98bbc8e9 (patch)
tree9c37786f54c3f0e9471653dbb942c69d59ed583d /test/profiling
parentf8d20172eb4a9e1f07112c70410dc027db0f7259 (diff)
something facilitating performance tests
Diffstat (limited to 'test/profiling')
-rw-r--r--test/profiling/main.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/profiling/main.c b/test/profiling/main.c
index 326cb68..c861f2e 100644
--- a/test/profiling/main.c
+++ b/test/profiling/main.c
@@ -78,15 +78,41 @@ void performance_cube_add_comprehensive()
tags[i].value_int = i;
}
getchar();
+ clock_t start, end;
struct fieldstat *instance = fieldstat_new();
fieldstat_register_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_COMPREHENSIVE, 64000);
fieldstat_register_counter(instance, 0, "test", 0);
+ start = clock();
for (int i = 0; i < 64000; i++) {
(void)fieldstat_cube_add(instance, 0, &tags[i], 1, 1);
}
+ end = clock();
+ printf("time: %f\n", (double)(end - start) / CLOCKS_PER_SEC);
+
fieldstat_free(instance);
}
+extern void build_dynamic_cell_key(const struct fieldstat_tag tags[], size_t n_tags, char **out_key, size_t *out_key_size);
+void build_dynamic_cell_key_performance()
+{
+ struct fieldstat_tag tags[100000];
+ for (int i = 0; i < 100000; i++) {
+ tags[i] = TEST_TAG_INT;
+ tags[i].value_int = i;
+ }
+ char *key;
+ size_t key_size;
+ clock_t start, end;
+ start = clock();
+ printf("start\n");
+ for (int i = 0; i < 100000; i++) {
+ build_dynamic_cell_key(&tags[i], 1, &key, &key_size);
+ free(key);
+ }
+ end = clock();
+ printf("time: %f\n", (double)(end - start) / CLOCKS_PER_SEC);
+}
+
void topk_K_100_tag_2()
{
printf("topk_K_100_tag_2\n");
@@ -119,5 +145,6 @@ void topk_K_100_tag_2()
int main () {
// try_hash_compound_key();
// topk_K_100_tag_2();
- performance_cube_add_comprehensive();
+ // performance_cube_add_comprehensive();
+ build_dynamic_cell_key_performance();
} \ No newline at end of file