GCC Code Coverage Report


Directory: ./
File: tasks/dergynov_s_radix_sort_double_simple_merge/seq/src/ops_seq.cpp
Date: 2026-02-23 23:20:07
Exec Total Coverage
Lines: 37 37 100.0%
Functions: 6 6 100.0%
Branches: 25 34 73.5%

Line Branch Exec Source
1 #include "dergynov_s_radix_sort_double_simple_merge/seq/include/ops_seq.hpp"
2
3 #include <cstddef>
4 #include <cstdint>
5 #include <cstring>
6 #include <vector>
7
8 #include "dergynov_s_radix_sort_double_simple_merge/common/include/common.hpp"
9
10 namespace dergynov_s_radix_sort_double_simple_merge {
11 namespace {
12
13
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 34 times.
50 void RadixSortDoubles(std::vector<double> &data) {
14
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 34 times.
50 if (data.size() <= 1) {
15 16 return;
16 }
17
18 34 std::vector<uint64_t> keys(data.size());
19
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 34 times.
260 for (size_t i = 0; i < data.size(); ++i) {
20
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 154 times.
452 keys[i] = DoubleToSortableUint64(data[i]);
21 }
22
23 const int k_radix = 256;
24
1/4
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
34 std::vector<uint64_t> temp(data.size());
25
26
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 34 times.
306 for (int shift = 0; shift < 64; shift += 8) {
27
1/4
✓ Branch 1 taken 272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
272 std::vector<size_t> count(k_radix + 1, 0);
28
29
2/2
✓ Branch 0 taken 1808 times.
✓ Branch 1 taken 272 times.
2080 for (uint64_t key : keys) {
30 1808 uint8_t digit = (key >> shift) & 0xFF;
31 1808 ++count[digit + 1];
32 }
33
34
2/2
✓ Branch 0 taken 69632 times.
✓ Branch 1 taken 272 times.
69904 for (int i = 0; i < k_radix; ++i) {
35 69632 count[i + 1] += count[i];
36 }
37
38
2/2
✓ Branch 0 taken 1808 times.
✓ Branch 1 taken 272 times.
2080 for (uint64_t key : keys) {
39 1808 uint8_t digit = (key >> shift) & 0xFF;
40 1808 size_t pos = count[digit];
41 1808 temp[pos] = key;
42 1808 ++count[digit];
43 }
44
45 keys.swap(temp);
46 }
47
48
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 34 times.
260 for (size_t i = 0; i < data.size(); ++i) {
49
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 72 times.
452 data[i] = SortableUint64ToDouble(keys[i]);
50 }
51 }
52
53 } // namespace
54
55
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
50 DergynovSRadixSortDoubleSimpleMergeSEQ::DergynovSRadixSortDoubleSimpleMergeSEQ(const InType &in) {
56 SetTypeOfTask(GetStaticTypeOfTask());
57
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
50 GetInput() = in;
58 sorted_.clear();
59 std::get<0>(GetOutput()).clear();
60 50 std::get<1>(GetOutput()) = -1;
61 50 }
62
63 50 bool DergynovSRadixSortDoubleSimpleMergeSEQ::ValidationImpl() {
64 50 return true;
65 }
66
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 bool DergynovSRadixSortDoubleSimpleMergeSEQ::PreProcessingImpl() {
68 sorted_.clear();
69 50 return true;
70 }
71
72 50 bool DergynovSRadixSortDoubleSimpleMergeSEQ::RunImpl() {
73 50 sorted_ = GetInput();
74 50 RadixSortDoubles(sorted_);
75 50 return true;
76 }
77
78 50 bool DergynovSRadixSortDoubleSimpleMergeSEQ::PostProcessingImpl() {
79 50 std::get<0>(GetOutput()) = sorted_;
80 50 std::get<1>(GetOutput()) = 0;
81 50 return true;
82 }
83
84 } // namespace dergynov_s_radix_sort_double_simple_merge
85