diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/src/gtest_dynamic_benchmark.cpp | 122 |
1 files changed, 115 insertions, 7 deletions
diff --git a/test/src/gtest_dynamic_benchmark.cpp b/test/src/gtest_dynamic_benchmark.cpp index 01e22e2..b93df70 100644 --- a/test/src/gtest_dynamic_benchmark.cpp +++ b/test/src/gtest_dynamic_benchmark.cpp @@ -8,6 +8,7 @@ #include <math.h> /* +date: 2023/9/5 spinlock, output interval: 1ms -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Thread num 1 | Thread num 2 | Thread num 4 | Thread num 8 | Thread num 16 | Thread num 32 | Thread num 64 | @@ -32,8 +33,7 @@ spinlock, output interval: 1ms -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 100,000,000 | 19,425,541 | 30,764,254 | 57,262,235 | 97,336,038 | 117,999,613 | 156,962,386 | 203,782,206 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -*/ -/* + no spinlock, output interval: 1ms -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Thread num 1 | Thread num 2 | Thread num 4 | Thread num 8 | Thread num 16 | Thread num 32 | Thread num 64 | @@ -58,8 +58,7 @@ no spinlock, output interval: 1ms -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 100,000,000 | 18,784,181 | 18,827,600 | 18,812,896 | 18,875,007 | 18,833,475 | 18,811,591 | 26,965,032 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -*/ -/* + spinlock with Struct Alignment, output interval: 1ms -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Thread num 1 | Thread num 2 | Thread num 4 | Thread num 8 | Thread num 16 | Thread num 32 | Thread num 64 | @@ -86,6 +85,112 @@ spinlock with Struct Alignment, output interval: 1ms -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ + +/* +date: 2023/9/6 + +no lock, output interval 1ms + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | | Thread num 1 | Thread num 2 | Thread num 4 | Thread num 8 | Thread num 16 | Thread num 32 | Thread num 64 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | operate counter | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1 | 42 | 28 | 17 | 22 | 59 | 42 | 40 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10 | 29 | 14 | 10 | 11 | 12 | 11 | 9 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100 | 32 | 31 | 34 | 31 | 32 | 30 | 29 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1,000 | 200 | 208 | 208 | 212 | 213 | 212 | 208 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10,000 | 1,989 | 1,975 | 1,953 | 1,932 | 1,952 | 1,958 | 1,948 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100,000 | 20,193 | 19,209 | 19,306 | 19,126 | 19,257 | 19,336 | 21,010 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1,000,000 | 193,482 | 191,674 | 192,383 | 192,317 | 193,822 | 192,023 | 254,656 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10,000,000 | 1,936,361 | 1,931,578 | 1,936,618 | 1,921,114 | 1,926,897 | 1,920,143 | 2,595,562 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100,000,000 | 19,245,473 | 19,243,094 | 19,204,994 | 19,193,001 | 19,196,800 | 19,181,999 | 27,619,589 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +spinlock, output interval 1ms + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | | Thread num 1 | Thread num 2 | Thread num 4 | Thread num 8 | Thread num 16 | Thread num 32 | Thread num 64 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | operate counter | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1 | 59 | 18 | 20 | 24 | 38 | 40 | 38 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10 | 27 | 13 | 12 | 13 | 11 | 11 | 9 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100 | 29 | 39 | 32 | 30 | 31 | 30 | 29 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1,000 | 209 | 211 | 327 | 203 | 207 | 206 | 203 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10,000 | 1,896 | 1,897 | 3,162 | 1,893 | 1,897 | 1,905 | 1,908 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100,000 | 18,734 | 18,718 | 31,251 | 18,751 | 18,738 | 18,820 | 20,910 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1,000,000 | 186,970 | 187,683 | 187,262 | 187,649 | 188,037 | 188,369 | 247,677 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10,000,000 | 1,877,762 | 1,880,236 | 1,876,492 | 1,875,297 | 1,878,232 | 1,879,564 | 2,603,063 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100,000,000 | 18,720,506 | 18,736,390 | 18,740,244 | 18,769,749 | 18,779,667 | 18,806,123 | 26,277,081 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +rwlock, output interval 1ms + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | | Thread num 1 | Thread num 2 | Thread num 4 | Thread num 8 | Thread num 16 | Thread num 32 | Thread num 64 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | operate counter | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1 | 52 | 18 | 18 | 48 | 61 | 41 | 44 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10 | 30 | 13 | 13 | 11 | 12 | 10 | 19 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100 | 42 | 37 | 34 | 34 | 34 | 31 | 32 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1,000 | 230 | 222 | 377 | 311 | 224 | 222 | 345 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10,000 | 2,101 | 2,369 | 6,710 | 2,944 | 3,537 | 2,069 | 3,560 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100,000 | 20,448 | 24,518 | 39,459 | 30,087 | 34,189 | 20,981 | 38,270 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1,000,000 | 204,923 | 272,109 | 205,070 | 307,572 | 397,855 | 209,094 | 411,857 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10,000,000 | 2,043,604 | 2,048,087 | 3,021,970 | 2,933,224 | 2,070,708 | 2,085,169 | 4,453,767 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100,000,000 | 20,413,678 | 20,465,977 | 26,326,140 | 29,201,649 | 20,692,983 | 20,822,775 | 46,712,568 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +mutex, output interval 1ms + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | | Thread num 1 | Thread num 2 | Thread num 4 | Thread num 8 | Thread num 16 | Thread num 32 | Thread num 64 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | operate counter | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | operation duration(us) | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1 | 53 | 15 | 29 | 24 | 41 | 44 | 40 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10 | 34 | 13 | 13 | 13 | 13 | 12 | 10 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100 | 37 | 34 | 33 | 31 | 35 | 31 | 31 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1,000 | 220 | 224 | 614 | 223 | 225 | 223 | 224 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10,000 | 2,108 | 2,113 | 4,294 | 2,111 | 2,110 | 2,132 | 2,167 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100,000 | 21,089 | 20,854 | 65,000 | 21,106 | 21,021 | 21,553 | 24,513 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 1,000,000 | 210,556 | 270,618 | 209,851 | 209,477 | 382,730 | 215,677 | 285,425 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 10,000,000 | 2,091,623 | 2,095,177 | 2,096,735 | 2,093,514 | 2,114,204 | 2,203,298 | 2,920,734 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + | 100,000,000 | 20,968,000 | 20,874,788 | 20,943,953 | 20,944,974 | 21,137,730 | 21,657,745 | 30,985,793 | + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +*/ + struct thread_para { int loops; @@ -108,6 +213,7 @@ void _worker_thread_one_metric(void *arg) int loops = para->loops; int thread_id = para->thread_id; struct fieldstat_dynamic_instance *instance = para->instance; + char metric_name[128] = {0}; int ret = 0; long long start_time, end_time; @@ -115,8 +221,10 @@ void _worker_thread_one_metric(void *arg) start_time = current_timestamp(); for(int i = 0; i < loops; i++) { + memset(metric_name, 0, sizeof(metric_name)); + snprintf(metric_name, sizeof(metric_name), "Active_sessions_%d", i); ret = fieldstat_dynamic_metric_value_incrby(instance, FIELD_TYPE_GAUGE, - "Active_sessions", 10, + metric_name, 10, NULL, 0, thread_id); EXPECT_EQ(0, ret); } @@ -196,10 +304,10 @@ TEST(FeildStatDynamicAPI, AllConditions) int n_thread = 0; int n_loops = 0; - for(int i = 0; i < 7; i++) + for(int i = 0; i < 5; i++) { n_thread = 1 << i; - for(int j = 0; j < 9; j++) + for(int j = 0; j < 6; j++) { n_loops = (int)pow(10, (double)j); fieldstat_dynamic_benchmark(n_thread, n_loops); |
