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

randombit / botan / 21768358452

06 Feb 2026 10:35PM UTC coverage: 90.064% (-0.003%) from 90.067%
21768358452

Pull #5289

github

web-flow
Merge f589db195 into 8ea0ca252
Pull Request #5289: Further misc header reductions, forward declarations, etc

102238 of 113517 relevant lines covered (90.06%)

11357432.36 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 <botan/rng.h>
11
#include <botan/internal/fmt.h>
12
#include <functional>
13
#include <iosfwd>
14
#include <map>
15
#include <memory>
16
#include <string>
17

18
#include "timer.h"
19

20
namespace Botan_CLI {
21

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

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

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

45
      uint64_t runtime() const { return m_runtime; }
48✔
46

47
      std::ostream& error_output() const { return m_error_output; }
×
48

49
      Botan::RandomNumberGenerator& rng() const { return m_rng; }
70✔
50

51
      void record_result(const Timer& timer) const { m_record_result(timer); }
295✔
52

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

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

72
class PerfTest /* NOLINT(*-special-member-functions) */ {
26✔
73
   public:
74
      virtual ~PerfTest() = default;
75

76
      // Returns nullptr if unknown / not available
77
      static std::unique_ptr<PerfTest> get(const std::string& alg);
78

79
      virtual void go(const PerfConfig& config) = 0;
80

81
      virtual std::string format_name(const std::string& alg, const std::string& param) const;
82

83
      typedef std::function<std::unique_ptr<PerfTest>()> pt_maker_fn;
84

85
      class Registration final {
86
         public:
87
            Registration(const std::string& name, const std::function<std::unique_ptr<PerfTest>()>& maker_fn);
88
      };
89

90
   private:
91
      static std::unique_ptr<PerfTest> get_sym(const std::string& alg);
92

93
      static std::map<std::string, pt_maker_fn>& global_registry();
94
};
95

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

102
}  // namespace Botan_CLI
103

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