]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/beast/test/extras/include/boost/beast/test/throughput.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / beast / test / extras / include / boost / beast / test / throughput.hpp
CommitLineData
b32b8144 1//
92f5a8d4 2// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
b32b8144
FG
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
16namespace boost {
17namespace beast {
18namespace test {
19
20class timer
21{
22 using clock_type =
23 std::chrono::system_clock;
24
25 clock_type::time_point when_;
26
27public:
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
43inline
44std::uint64_t
45throughput(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