forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-performance-01.cpp
More file actions
50 lines (43 loc) · 1.33 KB
/
test-performance-01.cpp
File metadata and controls
50 lines (43 loc) · 1.33 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
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: test-performance-01.cpp
@Time: 2023/12/3 17:41
@Desc:
***************************/
#include "../_Materials/TestInclude.h"
using namespace CGraph;
void test_performance_01() {
// 并行的执行32次,对应第1个例子,8thread,32并发,50w次
GPipelinePtr pipeline = GPipelineFactory::create();
CStatus status;
GElementPtr arr[32];
UThreadPoolConfig config;
config.default_thread_size_ = 8;
config.secondary_thread_size_ = 0;
config.max_task_steal_range_ = 7;
config.max_thread_size_ = 8;
config.primary_thread_policy_ = CGRAPH_THREAD_SCHED_RR;
config.primary_thread_priority_ = 10;
config.primary_thread_empty_interval_ = 0;
config.primary_thread_busy_epoch_ = 500;
config.monitor_enable_ = false; // 关闭扩缩容机制
pipeline->setUniqueThreadPoolConfig(config);
for (auto& i : arr) {
pipeline->registerGElement<TestAdd1GNode>(&i);
}
pipeline->setAutoCheck(false);
status += pipeline->init();
{
UTimeCounter counter("test_performance_01");
for (int t = 0; t < 500000; t++) {
pipeline->run();
}
}
status += pipeline->destroy();
GPipelineFactory::remove(pipeline);
}
int main() {
test_performance_01();
return 0;
}