Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
RcptTimerStats.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "cheetah/rcpt/RcptTimerStats.h"
25 
26 namespace ska {
27 namespace cheetah {
28 namespace rcpt {
29 
30 
31 template<typename ClockType>
32 RcptTimerStats<ClockType>::RcptTimerStats(std::size_t window_size)
33  : _data_rates(boost::accumulators::tag::rolling_window::window_size=window_size)
34  , _window_size(window_size)
35 {
36  reset();
37 }
38 
39 template<typename ClockType>
40 RcptTimerStats<ClockType>::~RcptTimerStats()
41 {
42 }
43 
44 template<typename ClockType>
45 void RcptTimerStats<ClockType>::operator()(typename BeamFormerDataTraits::DataType const& data, TimePointType time)
46 {
47  auto delta = std::chrono::duration_cast<std::chrono::duration<double>>(time - _last);
48  double data_rate = (data.data_size() * sizeof(typename BeamFormerDataTraits::DataType::DataType))/delta.count();
49  _data_rates(data_rate);
50  _last = ClockType::now();
51 }
52 
53 template<typename ClockType>
55 {
56  _last=ClockType::now();
57 }
58 
59 template<typename ClockType>
60 panda::DataRate<double> RcptTimerStats<ClockType>::data_rate() const
61 {
62  return panda::DataRate<double>(boost::accumulators::rolling_mean(_data_rates) * panda::bytes_per_second);
63 }
64 
65 template<typename StreamType, typename ClockType>
66 StreamType& operator<<(StreamType& os, RcptTimerStats<ClockType> const& stats)
67 {
68  os << stats.data_rate() << "\n";
69  return os;
70 }
71 
72 } // namespace rcpt
73 } // namespace cheetah
74 } // namespace ska
Definition: Units.h:112
panda::DataRate< double > data_rate() const
return the average data rate
Some limits and constants for FLDO.
Definition: Brdz.h:35
uint8_t DataType
the underlying data storage type for the amplitude of the signal
Definition: TimeFrequency.h:96
Calculate rcpt specific performance information.