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

randombit / botan / 21783203606

07 Feb 2026 04:30PM UTC coverage: 90.068% (-0.005%) from 90.073%
21783203606

Pull #5295

github

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

102233 of 113507 relevant lines covered (90.07%)

11542227.95 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

16
#include "timer.h"
17

18
namespace Botan {
19

20
class RandomNumberGenerator;
21

22
}
23

24
namespace Botan_CLI {
25

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

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

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

49
      uint64_t runtime() const { return m_runtime; }
104✔
50

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

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

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

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

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

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

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

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

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

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

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

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

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

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

106
}  // namespace Botan_CLI
107

108
#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