GCC Code Coverage Report


Directory: ./
File: tasks/akimov_i_radixsort_int_merge/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 28 28 100.0%
Functions: 5 5 100.0%
Branches: 17 24 70.8%

Line Branch Exec Source
1 #include "akimov_i_radixsort_int_merge/seq/include/ops_seq.hpp"
2
3 #include <cstdint>
4 #include <vector>
5
6 #include "akimov_i_radixsort_int_merge/common/include/common.hpp"
7
8 namespace akimov_i_radixsort_int_merge {
9
10
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 AkimovIRadixSortIntMergeSEQ::AkimovIRadixSortIntMergeSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 GetInput() = in;
13 24 GetOutput() = OutType();
14 24 }
15
16 24 bool AkimovIRadixSortIntMergeSEQ::ValidationImpl() {
17 24 return !GetInput().empty();
18 }
19
20 24 bool AkimovIRadixSortIntMergeSEQ::PreProcessingImpl() {
21 24 GetOutput() = GetInput();
22 24 return true;
23 }
24
25
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 bool AkimovIRadixSortIntMergeSEQ::RunImpl() {
26 auto &arr = GetOutput();
27
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (arr.empty()) {
28 return true;
29 }
30
31 constexpr int32_t kSignMask = INT32_MIN; // 0x80000000
32
2/2
✓ Branch 0 taken 8880 times.
✓ Branch 1 taken 24 times.
8904 for (int &x : arr) {
33 8880 x ^= kSignMask;
34 }
35
36 const int num_bytes = static_cast<int>(sizeof(int));
37 24 std::vector<int> temp(arr.size());
38
39
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for (int byte_pos = 0; byte_pos < num_bytes; ++byte_pos) {
40
1/4
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 std::vector<int> count(256, 0);
41
2/2
✓ Branch 0 taken 35520 times.
✓ Branch 1 taken 96 times.
35616 for (int x : arr) {
42 35520 uint8_t byte = (x >> (byte_pos * 8)) & 0xFF;
43 35520 ++count[byte];
44 }
45
46
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 96 times.
24576 for (int i = 1; i < 256; ++i) {
47 24480 count[i] += count[i - 1];
48 }
49
50
2/2
✓ Branch 0 taken 35520 times.
✓ Branch 1 taken 96 times.
35616 for (int i = static_cast<int>(arr.size()) - 1; i >= 0; --i) {
51 35520 uint8_t byte = (arr[i] >> (byte_pos * 8)) & 0xFF;
52 35520 temp[--count[byte]] = arr[i];
53 }
54
55 arr.swap(temp);
56 }
57
58
2/2
✓ Branch 0 taken 8880 times.
✓ Branch 1 taken 24 times.
8904 for (int &x : arr) {
59 8880 x ^= kSignMask;
60 }
61
62 return true;
63 }
64
65 24 bool AkimovIRadixSortIntMergeSEQ::PostProcessingImpl() {
66 24 return true;
67 }
68
69 } // namespace akimov_i_radixsort_int_merge
70