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

randombit / botan / 21786344715

07 Feb 2026 08:25PM UTC coverage: 90.068% (-0.005%) from 90.073%
21786344715

Pull #5295

github

web-flow
Merge 8d5fc3b23 into ebf8f0044
Pull Request #5295: Reduce header dependencies in tests and cli

102234 of 113507 relevant lines covered (90.07%)

11372278.81 hits per line

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

94.74
/src/cli/perf.h
1
/*
2
* (C) 2024 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#ifndef BOTAN_CLI_PERF_H_
8
#define BOTAN_CLI_PERF_H_
9

10
#include <functional>
11
#include <iosfwd>
12
#include <map>
13
#include <memory>
14
#include <string>
15
#include <vector>
16

17
#include "timer.h"
18

19
namespace Botan {
20

21
class RandomNumberGenerator;
22

23
}
24

25
namespace Botan_CLI {
26

27
class PerfConfig final {
28
   public:
29
      PerfConfig(std::function<void(const Timer&)> record_result,
10✔
30
                 size_t clock_speed,
31
                 double clock_cycle_ratio,
32
                 uint64_t runtime,
33
                 const std::vector<std::string>& ecc_groups,
34
                 const std::vector<size_t>& buffer_sizes,
35
                 std::ostream& error_output,
36
                 Botan::RandomNumberGenerator& rng) :
10✔
37
            m_record_result(std::move(record_result)),
10✔
38
            m_clock_speed(clock_speed),
10✔
39
            m_clock_cycle_ratio(clock_cycle_ratio),
10✔
40
            m_runtime(runtime),
10✔
41
            m_ecc_groups(ecc_groups),
10✔
42
            m_buffer_sizes(buffer_sizes),
10✔
43
            m_error_output(error_output),
10✔
44
            m_rng(rng) {}
10✔
45

46
      const std::vector<size_t>& buffer_sizes() const { return m_buffer_sizes; }
15✔
47

48
      const std::vector<std::string>& ecc_groups() const { return m_ecc_groups; }
4✔
49

50
      uint64_t runtime() const { return m_runtime; }
76✔
51

52
      std::ostream& error_output() const { return m_error_output; }
×
53

54
      Botan::RandomNumberGenerator& rng() const { return m_rng; }
70✔
55

56
      void record_result(const Timer& timer) const { m_record_result(timer); }
295✔
57

58
      std::unique_ptr<Timer> make_timer(const std::string& alg,
173✔
59
                                        uint64_t event_mult = 1,
60
                                        const std::string& what = "",
61
                                        const std::string& provider = "",
62
                                        size_t buf_size = 0) const {
63
         return std::make_unique<Timer>(alg, provider, what, event_mult, buf_size, m_clock_cycle_ratio, m_clock_speed);
173✔
64
      }
65

66
   private:
67
      std::function<void(const Timer&)> m_record_result;
68
      size_t m_clock_speed = 0;
69
      double m_clock_cycle_ratio = 0.0;
70
      uint64_t m_runtime;
71
      std::vector<std::string> m_ecc_groups;
72
      std::vector<size_t> m_buffer_sizes;
73
      std::ostream& m_error_output;
74
      Botan::RandomNumberGenerator& m_rng;
75
};
76

77
class PerfTest /* NOLINT(*-special-member-functions) */ {
25✔
78
   public:
79
      virtual ~PerfTest() = default;
80

81
      // Returns nullptr if unknown / not available
82
      static std::unique_ptr<PerfTest> get(const std::string& alg);
83

84
      virtual void go(const PerfConfig& config) = 0;
85

86
      virtual std::string format_name(const std::string& alg, const std::string& param) const;
87

88
      typedef std::function<std::unique_ptr<PerfTest>()> pt_maker_fn;
89

90
      class Registration final {
91
         public:
92
            Registration(const std::string& name, const std::function<std::unique_ptr<PerfTest>()>& maker_fn);
93
      };
94

95
   private:
96
      static std::unique_ptr<PerfTest> get_sym(const std::string& alg);
97

98
      static std::map<std::string, pt_maker_fn>& global_registry();
99
};
100

101
// NOLINTNEXTLINE(*-macro-usage)
102
#define BOTAN_REGISTER_PERF_TEST(name, Perf_Class)                \
103
   /* NOLINTNEXTLINE(cert-err58-cpp) */                           \
104
   const Botan_CLI::PerfTest::Registration reg_perf_##Perf_Class( \
105
      name, []() -> std::unique_ptr<Botan_CLI::PerfTest> { return std::make_unique<Perf_Class>(); })
106

107
}  // namespace Botan_CLI
108

109
#endif
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