forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-performance-03.cpp
More file actions
53 lines (46 loc) · 1.64 KB
/
test-performance-03.cpp
File metadata and controls
53 lines (46 loc) · 1.64 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
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: test-performance-03.cpp
@Time: 2023/12/3 18:29
@Desc:
***************************/
#include "../_Materials/TestInclude.h"
using namespace CGraph;
void test_performance_03() {
// 简单dag场景,对应第三个例子,2thread,dag,100w次
GPipelinePtr pipeline = GPipelineFactory::create();
CStatus status;
GElementPtr a,b1,b2,c1,c2,d = nullptr;
UThreadPoolConfig config;
config.default_thread_size_ = 2; // 我的笔记本,是8核心的 macbook pro m1
config.secondary_thread_size_ = 0;
config.max_task_steal_range_ = 1;
config.max_thread_size_ = 2;
config.primary_thread_empty_interval_ = 0;
config.primary_thread_busy_epoch_ = 500;
config.monitor_enable_ = false; // 关闭扩缩容机制
config.primary_thread_policy_ = CGRAPH_THREAD_SCHED_RR;
config.primary_thread_priority_ = 10;
pipeline->setUniqueThreadPoolConfig(config);
pipeline->setAutoCheck(false);
pipeline->registerGElement<TestAdd1GNode>(&a);
pipeline->registerGElement<TestAdd1GNode>(&b1, {a});
pipeline->registerGElement<TestAdd1GNode>(&b2, {b1});
pipeline->registerGElement<TestAdd1GNode>(&c1, {a});
pipeline->registerGElement<TestAdd1GNode>(&c2, {c1});
pipeline->registerGElement<TestAdd1GNode>(&d, {b2, c2});
status += pipeline->init();
{
UTimeCounter counter("test_performance_03");
for (int t = 0; t < 1000000; t++) {
pipeline->run();
}
}
status += pipeline->destroy();
GPipelineFactory::remove(pipeline);
}
int main() {
test_performance_03();
return 0;
}