forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-functional-04.cpp
More file actions
54 lines (42 loc) · 1.61 KB
/
test-functional-04.cpp
File metadata and controls
54 lines (42 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: test-functional-04.cpp
@Time: 2024/1/1 00:53
@Desc:
***************************/
#include "../_Materials/TestInclude.h"
using namespace CGraph;
void test_functional_04() {
const int HALF_ARR_SIZE = 32;
const int RUN_TIMES = 100000;
CGRAPH_CREATE_MESSAGE_TOPIC(TestGMessageParam, g_test_message_key, 100)
std::unique_ptr<TestGMessageParam> mp(new TestGMessageParam());
CGRAPH_SEND_MPARAM(TestGMessageParam, g_test_message_key, mp, GMessagePushStrategy::WAIT)
GPipelinePtr pipeline = GPipelineFactory::create();
GElementPtr arr[HALF_ARR_SIZE * 2]; // 前面一半是串行的,后面一半是并行的
GElementPtrSet linearSet;
CStatus status = pipeline->registerGElement<TestRecvMessageGNode>(&arr[0]);
linearSet.insert(arr[0]);
for (int i = 1; i < HALF_ARR_SIZE; i++) {
status += pipeline->registerGElement<TestRecvMessageGNode>(&arr[i], {arr[i-1]});
linearSet.insert(arr[i]);
}
for (int j = HALF_ARR_SIZE; j < HALF_ARR_SIZE * 2; j++) {
status += pipeline->registerGElement<TestRecvMessageGNode>(&arr[j], linearSet);
}
{
UTimeCounter counter("test_functional_04");
status += pipeline->process(RUN_TIMES);
}
status += CGRAPH_RECV_MPARAM_WITH_TIMEOUT(TestGMessageParam, g_test_message_key, mp, 10)
if (mp->num_ != HALF_ARR_SIZE * RUN_TIMES * 2) {
CGRAPH_ECHO("result num is wrong, num is [%lu]", mp->num_);
}
CGRAPH_CLEAR_MESSAGES()
GPipelineFactory::clear();
}
int main() {
test_functional_04();
return 0;
}