summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuyu <[email protected]>2024-07-02 23:09:58 +0800
committerliuyu <[email protected]>2024-07-02 23:09:58 +0800
commit72de99bb849e81e22c9e845b76c996d7b001e047 (patch)
tree8ed33250bee92dbb2de629aa344126c95689da13
parent064cf180cca905d83e01653e5d4bec24f7f62a36 (diff)
修改benchmark,每个入队的值都不同,保证数据准确性
-rw-r--r--bbq/tests/common/test_queue.c25
-rw-r--r--bbq/tests/common/test_queue.h11
-rw-r--r--perf/benchmark/bcm_loadconfig.c7
3 files changed, 29 insertions, 14 deletions
diff --git a/bbq/tests/common/test_queue.c b/bbq/tests/common/test_queue.c
index a833843..5d88997 100644
--- a/bbq/tests/common/test_queue.c
+++ b/bbq/tests/common/test_queue.c
@@ -1,6 +1,6 @@
/*
* @Author: liuyu
- * @LastEditTime: 2024-07-01 23:56:45
+ * @LastEditTime: 2024-07-02 23:07:37
* @Describe: TODO
*/
@@ -84,7 +84,7 @@ test_exit_data *test_exit_data_create(test_thread_arg_s *t_arg) {
size_t size = t_arg->test_info->cfg.ring.entries_cnt;
exit_data->simple_data_cnt = size;
- exit_data->simple_data = test_data_create(size);
+ exit_data->simple_data = test_data_create(size, TEST_DATA_MAGIC_TYPE);
if (exit_data->simple_data == NULL) {
TEST_ERR_LOG("malloc failed");
@@ -104,12 +104,16 @@ void test_exit_data_destory(test_exit_data *data) {
test_free(TEST_MODULE_COMMON, data);
}
-test_data **test_data_create(size_t cnt) {
+test_data **test_data_create(size_t cnt, enum test_data_type data_type) {
test_data **simple_data = test_malloc(TEST_MODULE_DATA, sizeof(*simple_data) * cnt);
test_time_metric enqueue_time = test_clock_time_get();
for (size_t i = 0; i < cnt; i++) {
simple_data[i] = test_malloc(TEST_MODULE_DATA, sizeof(*simple_data[i]));
- simple_data[i]->data = TEST_DATA_MAGIC;
+ if (data_type == TEST_DATA_MAGIC_TYPE) {
+ simple_data[i]->data = TEST_DATA_MAGIC;
+ } else {
+ simple_data[i]->data = (uintptr_t)(simple_data[i]);
+ }
simple_data[i]->enqueue_time = enqueue_time;
}
@@ -179,14 +183,15 @@ void *test_thread_producer_start(void *arg) {
if (cfg->ring.workload == TEST_WORKLOAD_SIMPLE) {
enqueue_cnt = test_exec_enqueue(q, exit_data->simple_data, cfg->ring.burst_cnt, &op_latency, t_arg->thread_idx);
} else {
- // 由于rmind不支持指定个数的批量出队列,为了兼容它,这里分配的空间位置entries大小。
- test_data **data = test_data_create(cfg->ring.entries_cnt);
+ test_data **data = test_data_create(cfg->ring.burst_cnt, TEST_DATA_UINTPTR_TYPE);
if (data == NULL) {
TEST_ERR_LOG("malloc falied");
exit(-1);
}
+
enqueue_cnt = test_exec_enqueue(q, data, cfg->ring.burst_cnt, &op_latency, t_arg->thread_idx);
- for (uint32_t i = enqueue_cnt; i < cfg->ring.entries_cnt; i++) {
+ // 释放未入队的内存
+ for (uint32_t i = enqueue_cnt; i < cfg->ring.burst_cnt; i++) {
test_free(TEST_MODULE_DATA, data[i]);
}
@@ -256,7 +261,7 @@ void *test_thread_consumer_start(void *arg) {
test_data *data = deq_data[i];
if (cfg->ring.workload == TEST_WORKLOAD_SIMPLE) {
if (data->data != TEST_DATA_MAGIC) {
- TEST_ERR_LOG("the obtained data is not consistent with the expectation, expect:%u actual:%u", TEST_DATA_MAGIC, data->data);
+ TEST_ERR_LOG("the obtained data is not consistent with the expectation, expect:%u actual:%lu", TEST_DATA_MAGIC, data->data);
exit_data->data_error_cnt += 1;
}
} else {
@@ -266,8 +271,8 @@ void *test_thread_consumer_start(void *arg) {
exit(-1);
}
- if (data->data != TEST_DATA_MAGIC) {
- TEST_ERR_LOG("the obtained data is not consistent with the expectation, expect:%u actual:%u", TEST_DATA_MAGIC, data->data);
+ if (data->data != (uintptr_t)data) {
+ TEST_ERR_LOG("the obtained data is not consistent with the expectation, expect:%lu actual:%lu", (uintptr_t)data, data->data);
data_error_cnt += 1;
}
diff --git a/bbq/tests/common/test_queue.h b/bbq/tests/common/test_queue.h
index 9edefdb..3fc090f 100644
--- a/bbq/tests/common/test_queue.h
+++ b/bbq/tests/common/test_queue.h
@@ -1,6 +1,6 @@
/*
* @Author: liuyu
- * @LastEditTime: 2024-06-21 18:05:44
+ * @LastEditTime: 2024-07-02 22:40:17
* @Describe: TODO
*/
@@ -38,7 +38,7 @@ typedef struct {
} test_thread_arg_s;
typedef struct bcm_benchmark {
- uint32_t data; // 数据
+ uint64_t data; // 数据
test_time_metric enqueue_time; // 入队时间
} test_data;
@@ -77,6 +77,11 @@ typedef struct {
test_merge_data consumer;
} test_merge_s;
+enum test_data_type {
+ TEST_DATA_MAGIC_TYPE,
+ TEST_DATA_UINTPTR_TYPE,
+};
+
extern void test_threads_destory(test_info_s *test_info, pthread_t *threads);
extern pthread_t *test_threads_create(test_info_s *test_info, test_queue_s *q);
extern void test_one_thread_create(test_info_s *test_info, test_queue_s *q, test_thread_type_e ttype, int core, uint16_t thread_id, pthread_t *thread);
@@ -95,6 +100,6 @@ extern uint64_t bbq_head_idx(struct bbq *q, uint64_t x);
extern uint64_t bbq_cur_off(struct bbq *q, uint64_t x);
extern uint64_t bbq_head_vsn(struct bbq *q, uint64_t x);
extern uint64_t bbq_cur_vsn(struct bbq *q, uint64_t x);
-extern test_data **test_data_create(size_t cnt);
+extern test_data **test_data_create(size_t cnt, enum test_data_type);
extern void test_data_destory(test_data **data, size_t cnt);
#endif \ No newline at end of file
diff --git a/perf/benchmark/bcm_loadconfig.c b/perf/benchmark/bcm_loadconfig.c
index 53dbc6a..9968cf9 100644
--- a/perf/benchmark/bcm_loadconfig.c
+++ b/perf/benchmark/bcm_loadconfig.c
@@ -1,6 +1,6 @@
/*
* @Author: liuyu
- * @LastEditTime: 2024-06-14 16:48:29
+ * @LastEditTime: 2024-07-02 23:02:53
* @Describe: TODO
*/
@@ -53,6 +53,11 @@ int test_load_config(const char *config, const char *ring_type, uint32_t burst_c
TEST_ERR_LOG("ring type:%s only support burst_cnt > 1 !", TEST_RING_TYPE_RMIND_STR);
return -1;
}
+
+ if (cfg->ring.workload == TEST_WORKLOAD_COMPLEX) {
+ TEST_ERR_LOG("ring type:%s only support simple workload !", TEST_RING_TYPE_RMIND_STR);
+ return -1;
+ }
}
if (cfg->run.run_time == 0 && cfg->run.run_ok_times == 0) {