• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dedicate-project / beast / 5908912e-2396-46c2-b03d-62e16fdb292e

pending completion
5908912e-2396-46c2-b03d-62e16fdb292e

Pull #9

circleci

fairlight1337
Added [[nodiscard]] attributes and fixed code smells
Pull Request #9: Adding pipeline applications

1195 of 1195 new or added lines in 21 files covered. (100.0%)

2835 of 3040 relevant lines covered (93.26%)

16628.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.62
/src/evaluators/random_serial_data_passthrough_evaluator.cpp
1
#include <beast/evaluators/random_serial_data_passthrough_evaluator.hpp>
2

3
// Standard
4
#include <limits>
5
#include <random>
6

7
// BEAST
8
#include <beast/cpu_virtual_machine.hpp>
9

10
namespace beast {
11

12
RandomSerialDataPassthroughEvaluator::RandomSerialDataPassthroughEvaluator(uint32_t data_count,
16✔
13
                                                                           uint32_t repeats,
14
                                                                           uint32_t max_steps)
16✔
15
    : data_count_{data_count}, repeats_{repeats}, max_steps_{max_steps} {}
16✔
16

17
double RandomSerialDataPassthroughEvaluator::evaluate(const VmSession& session) {
5,585✔
18
  std::random_device random_device;
11,170✔
19
  std::mt19937 mersenne_twister(random_device());
5,585✔
20
  std::uniform_int_distribution<> distribution(std::numeric_limits<int32_t>::min(),
21
                                               std::numeric_limits<int32_t>::max());
5,585✔
22

23
  double worst_result = 1.0;
5,585✔
24
  for (uint32_t repeat = 0; repeat < repeats_; ++repeat) {
19,287✔
25
    std::vector<int32_t> values;
16,561✔
26
    for (uint32_t idx = 0; idx < data_count_; ++idx) {
33,122✔
27
      values.push_back(distribution(mersenne_twister));
16,561✔
28
    }
29

30
    // Make a copy because we're changing the state of the session.
31
    VmSession work_session = session;
16,561✔
32
    uint32_t correct_forwards = 0;
16,561✔
33

34
    work_session.setVariableBehavior(0, beast::VmSession::VariableIoBehavior::Input);
16,561✔
35
    work_session.setVariableBehavior(1, beast::VmSession::VariableIoBehavior::Output);
16,561✔
36

37
    work_session.setVariableValue(0, true, values[0]);
16,561✔
38

39
    try {
40
      correct_forwards = runProgram(work_session, values);
16,561✔
41
    } catch (...) {
2,859✔
42
      return 0.0;
2,859✔
43
    }
44

45
    const double result =
46
        std::min(1.0,
27,404✔
47
                 (static_cast<double>(correct_forwards) / static_cast<double>(values.size())) +
13,702✔
48
                     (correct_forwards == 0 ? static_cast<double>(values.size()) * 0.1 : 0.0));
13,702✔
49
    worst_result = std::min(worst_result, result);
13,702✔
50
  }
51

52
  return worst_result;
2,726✔
53
}
54

55
uint32_t
56
RandomSerialDataPassthroughEvaluator::runProgram(VmSession& work_session,
16,561✔
57
                                                 const std::vector<int32_t>& values) const {
58
  beast::CpuVirtualMachine virtual_machine;
16,561✔
59
  virtual_machine.setSilent(true);
16,561✔
60

61
  uint32_t value_index = 0;
16,561✔
62
  uint32_t step_count = 0;
16,561✔
63
  uint32_t correct_forwards = 0;
16,561✔
64

65
  do {
76,321✔
66
    if (work_session.hasOutputDataAvailable(1, true)) {
92,882✔
67
      if (work_session.getVariableValue(1, true) == values[value_index]) {
7,660✔
68
        correct_forwards++;
1,066✔
69
      }
70
      value_index++;
7,660✔
71
      if (value_index < values.size()) {
7,660✔
72
        work_session.setVariableValue(0, true, values[value_index]);
×
73
      }
74
    }
75
    step_count++;
92,876✔
76
  } while (value_index < values.size() && step_count < max_steps_ &&
174,602✔
77
           virtual_machine.step(work_session, false));
84,579✔
78

79
  return correct_forwards;
13,702✔
80
}
81

82
} // namespace beast
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc