FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/benchmarks/fibonacci/taskflow.cpp at master · feiyunwill/cpp-taskflow · GitHub
feiyunwill
/
cpp-taskflow
Public
forked from
taskflow/taskflow
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
benchmarks
/
fibonacci
/
taskflow.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (24 loc) · 900 Bytes
Breadcrumbs
cpp-taskflow
/
benchmarks
/
fibonacci
/
taskflow.cpp
Copy path
File metadata and controls
37 lines (24 loc) · 900 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
<
taskflow/taskflow.hpp
>
#
include
"
fibonacci.hpp
"
//
fibonacci computation
size_t
fibonacci
(
size_t
n, tf::Executor& executor) {
if
(n <
2
) {
return
n;
}
size_t
res1, res2;
tf::TaskGroup tg = executor.
task_group
();
tg.
silent_async
([n, &res1, &executor](){ res1 =
fibonacci
(n-
1
, executor); });
res2 =
fibonacci
(n-
2
, executor);
tg.
corun
();
return
res1 + res2;
}
size_t
fibonacci_taskflow
(tf::Executor& executor,
size_t
n) {
return
executor.
async
([n, &executor](){
return
fibonacci
(n, executor); }).
get
();
}
std::chrono::microseconds
measure_time_taskflow
(
size_t
num_threads,
size_t
n) {
static
tf::Executor
executor
(num_threads);
auto
beg =
std::chrono::high_resolution_clock::now
();
fibonacci_taskflow
(executor, n);
auto
end =
std::chrono::high_resolution_clock::now
();
return
std::chrono::duration_cast<std::chrono::microseconds>(end - beg);
}
Back
|
FazBrowse Home
|
New Git URL