GCC Code Coverage Report


Directory: ./
File: tasks/example/threads/stl/src/ops_stl.cpp
Date: 2026-08-18 01:54:56
Exec Total Coverage
Lines: 26 26 100.0%
Functions: 5 5 100.0%
Branches: 14 18 77.8%

Line Branch Exec Source
1 #include "example/threads/stl/include/ops_stl.hpp"
2
3 #include <atomic>
4 #include <numeric>
5 #include <thread>
6 #include <vector>
7
8 #include "example/common/include/common.hpp"
9 #include "util/include/util.hpp"
10
11 namespace example_threads {
12
13 24 NesterovATestTaskSTL::NesterovATestTaskSTL(const InType &in) : BaseTask(in) {}
14
15 24 bool NesterovATestTaskSTL::ValidationImpl() {
16
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 return (GetInput() > 0) && (GetMutableOutput() == 0);
17 }
18
19 24 bool NesterovATestTaskSTL::PreProcessingImpl() {
20 24 GetMutableOutput() = 2 * GetInput();
21 24 return GetMutableOutput() > 0;
22 }
23
24 24 bool NesterovATestTaskSTL::RunImpl() {
25
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 24 times.
96 for (InType i = 0; i < GetInput(); i++) {
26
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 72 times.
288 for (InType j = 0; j < GetInput(); j++) {
27
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 216 times.
864 for (InType k = 0; k < GetInput(); k++) {
28 648 std::vector<InType> tmp(i + j + k, 1);
29 648 GetMutableOutput() += std::accumulate(tmp.begin(), tmp.end(), 0);
30
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 24 times.
648 GetMutableOutput() -= i + j + k;
31 }
32 }
33 }
34
35 24 const int num_threads = ppc::util::GetNumThreads();
36 24 std::vector<std::thread> threads(num_threads);
37 24 GetMutableOutput() *= num_threads;
38
39 24 std::atomic<int> counter(0);
40
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 24 times.
84 for (std::thread &thread : threads) {
41
1/2
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
60 thread = std::thread([&counter]() -> void { counter++; });
42
1/2
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
60 thread.join();
43 }
44
45 24 GetMutableOutput() /= counter;
46 24 return GetMutableOutput() > 0;
47 24 }
48
49 24 bool NesterovATestTaskSTL::PostProcessingImpl() {
50 24 GetMutableOutput() -= GetInput();
51 24 return GetMutableOutput() > 0;
52 }
53
54 } // namespace example_threads
55