Skip to content

Commit

Permalink
[perf] optimise UTask, change some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Jan 14, 2024
1 parent 7542a71 commit 893b53e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
Empty file modified CGraph-ninja-build.sh
100644 → 100755
Empty file.
7 changes: 3 additions & 4 deletions src/UtilsCtrl/ThreadPool/Task/UTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UTask : public UThreadObject {
struct TaskDerided : TaskBased {
T func_;
explicit TaskDerided(F&& func) : func_(std::forward<F>(func)) {}
CVoid call() override { func_(); }
CVoid call() final { func_(); }
};

public:
Expand All @@ -39,9 +39,8 @@ class UTask : public UThreadObject {
, priority_(priority) {}

CVoid operator()() {
if (likely(impl_)) {
impl_->call();
}
// impl_ 理论上不可能为空
impl_ ? impl_->call() : throw CException("UTask inner function is nullptr");
}

UTask() = default;
Expand Down
2 changes: 1 addition & 1 deletion test/Performance/test-performance-01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void test_performance_01() {
config.max_thread_size_ = 8;
config.primary_thread_policy_ = CGRAPH_THREAD_SCHED_RR;
config.primary_thread_priority_ = 10;
config.primary_thread_empty_interval_ = 1;
config.primary_thread_empty_interval_ = 0;
config.primary_thread_busy_epoch_ = 500;
config.monitor_enable_ = false; // 关闭扩缩容机制
pipeline->setUniqueThreadPoolConfig(config);
Expand Down
2 changes: 1 addition & 1 deletion test/Performance/test-performance-03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void test_performance_03() {
config.secondary_thread_size_ = 0;
config.max_task_steal_range_ = 1;
config.max_thread_size_ = 2;
config.primary_thread_empty_interval_ = 1;
config.primary_thread_empty_interval_ = 0;
config.primary_thread_busy_epoch_ = 500;
config.monitor_enable_ = false; // 关闭扩缩容机制
config.primary_thread_policy_ = CGRAPH_THREAD_SCHED_RR;
Expand Down

0 comments on commit 893b53e

Please sign in to comment.