GCC Code Coverage Report


Directory: ./
File: tasks/zagryadskov_m_radix_sort_double_simple_merge/seq/src/radix_sort_double_simple_merge.cpp
Date: 2026-01-09 01:27:18
Exec Total Coverage
Lines: 39 39 100.0%
Functions: 7 7 100.0%
Branches: 17 22 77.3%

Line Branch Exec Source
1 #include "zagryadskov_m_radix_sort_double_simple_merge/seq/include/radix_sort_double_simple_merge.hpp"
2
3 #include <array>
4 #include <cstddef>
5 #include <cstdint>
6 #include <cstdlib>
7 #include <cstring>
8 #include <utility>
9 #include <vector>
10
11 #include "zagryadskov_m_radix_sort_double_simple_merge/common/include/common.hpp"
12
13 namespace zagryadskov_m_radix_sort_double_simple_merge {
14
15
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 ZagryadskovMRadixSortDoubleSimpleMergeSEQ::ZagryadskovMRadixSortDoubleSimpleMergeSEQ(const InType &in) {
16 SetTypeOfTask(GetStaticTypeOfTask());
17
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 GetInput() = in;
18 24 }
19
20 24 bool ZagryadskovMRadixSortDoubleSimpleMergeSEQ::ValidationImpl() {
21 24 return !GetInput().empty();
22 }
23
24 24 bool ZagryadskovMRadixSortDoubleSimpleMergeSEQ::PreProcessingImpl() {
25 24 return true;
26 }
27
28 240 void ZagryadskovMRadixSortDoubleSimpleMergeSEQ::Foffset(const uint8_t *mas, size_t size, size_t offset,
29 std::array<uint64_t, 256> &count) {
30 size_t i = 0;
31 uint64_t tmp = 0;
32 memset(count.data(), 0, (255ULL + 1ULL) * sizeof(uint64_t));
33
2/2
✓ Branch 0 taken 72009576 times.
✓ Branch 1 taken 240 times.
72009816 for (i = 0; i < size * sizeof(double); i += sizeof(double)) {
34 72009576 count.at(mas[i + offset])++;
35 }
36 240 tmp = count[0ULL];
37 240 count[0ULL] = 0ULL;
38
2/2
✓ Branch 0 taken 61200 times.
✓ Branch 1 taken 240 times.
61440 for (i = 0ULL; i < 255ULL; i++) {
39 61200 std::swap(tmp, count.at(i + 1));
40 61200 count.at(i + 1) += count.at(i);
41 }
42 240 }
43
44 30 void ZagryadskovMRadixSortDoubleSimpleMergeSEQ::RadixSortLSD(double *mas, size_t size) {
45 size_t i = 0;
46 size_t j = 0;
47 size_t k = 0;
48 size_t tidy_const = 0;
49 uint8_t *pm = nullptr;
50 30 std::array<uint64_t, 256> count{};
51 30 std::vector<double> vec_buf(size);
52 double *mas2 = vec_buf.data();
53 pm = reinterpret_cast<uint8_t *>(mas);
54
55
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 30 times.
270 for (i = 0ULL; i < sizeof(double); i++) {
56 240 Foffset(pm, size, i, count);
57
2/2
✓ Branch 0 taken 72009576 times.
✓ Branch 1 taken 240 times.
72009816 for (j = 0ULL; j < size; j++) {
58 72009576 tidy_const = count.at(pm[(j * sizeof(double)) + i]);
59 72009576 mas2[tidy_const] = mas[j];
60 72009576 count.at(pm[(j * sizeof(double)) + i])++;
61 }
62 std::swap(mas, mas2);
63 pm = reinterpret_cast<uint8_t *>(mas);
64 }
65
66 k = 0ULL;
67
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (mas[size - 1ULL] < 0.0) {
68
1/2
✓ Branch 0 taken 4499985 times.
✗ Branch 1 not taken.
4499985 for (i = size; i > 0ULL; i--) {
69
2/2
✓ Branch 0 taken 4499955 times.
✓ Branch 1 taken 30 times.
4499985 if (mas[i - 1] > 0.0) {
70 break;
71 }
72 4499955 mas2[k++] = mas[i - 1ULL];
73 }
74
75
1/2
✓ Branch 0 taken 4501272 times.
✗ Branch 1 not taken.
4501272 for (i = 0ULL; i < size; i++) {
76
2/2
✓ Branch 0 taken 4501242 times.
✓ Branch 1 taken 30 times.
4501272 if (mas[i] < 0.0) {
77 break;
78 }
79 4501242 mas2[k++] = mas[i];
80 }
81
82 memcpy(mas, mas2, size * sizeof(double));
83 }
84 30 }
85
86 24 bool ZagryadskovMRadixSortDoubleSimpleMergeSEQ::RunImpl() {
87 24 GetOutput() = GetInput();
88 24 RadixSortLSD(GetOutput().data(), GetOutput().size());
89
90 24 return !GetOutput().empty();
91 }
92
93 24 bool ZagryadskovMRadixSortDoubleSimpleMergeSEQ::PostProcessingImpl() {
94 24 return true;
95 }
96
97 } // namespace zagryadskov_m_radix_sort_double_simple_merge
98