]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/extras/include/boost/beast/test/throughput.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / beast / test / extras / include / boost / beast / test / throughput.hpp
1 //
2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9
10 #ifndef BOOST_BEAST_TEST_THROUGHPUT_HPP
11 #define BOOST_BEAST_TEST_THROUGHPUT_HPP
12
13 #include <chrono>
14 #include <cstdint>
15
16 namespace boost {
17 namespace beast {
18 namespace test {
19
20 class timer
21 {
22 using clock_type =
23 std::chrono::system_clock;
24
25 clock_type::time_point when_;
26
27 public:
28 using duration =
29 clock_type::duration;
30
31 timer()
32 : when_(clock_type::now())
33 {
34 }
35
36 duration
37 elapsed() const
38 {
39 return clock_type::now() - when_;
40 }
41 };
42
43 inline
44 std::uint64_t
45 throughput(std::chrono::duration<
46 double> const& elapsed, std::uint64_t items)
47 {
48 using namespace std::chrono;
49 return static_cast<std::uint64_t>(
50 1 / (elapsed/items).count());
51 }
52
53 } // test
54 } // beast
55 } // boost
56
57 #endif