LCOV - code coverage report
Current view: top level - src/Module/Probe/Latency - Probe_latency.cpp (source / functions) Hit Total Coverage
Test: streampu_clean.info Lines: 22 26 84.6 %
Date: 2024-06-12 12:04:18 Functions: 4 4 100.0 %

          Line data    Source code
       1             : #include <ios>
       2             : #include <sstream>
       3             : 
       4             : #include "Module/Probe/Latency/Probe_latency.hpp"
       5             : #include "Tools/Exception/exception.hpp"
       6             : 
       7             : using namespace spu;
       8             : using namespace spu::module;
       9             : 
      10          14 : Probe_latency::Probe_latency(const std::string& col_name, tools::Reporter_probe* reporter)
      11             :   : Probe<uint8_t>(0, col_name)
      12          14 :   , t_start(std::chrono::steady_clock::now())
      13             : {
      14          14 :     const std::string name = "Probe_latency<" + col_name + ">";
      15          14 :     this->set_name(name);
      16          14 :     this->set_single_wave(true);
      17             : 
      18          14 :     if (reporter != nullptr) this->register_reporter(reporter);
      19          14 : }
      20             : 
      21             : void
      22          14 : Probe_latency::register_reporter(tools::Reporter_probe* reporter)
      23             : {
      24          14 :     if (this->reporter != nullptr)
      25             :     {
      26           0 :         std::stringstream message;
      27             :         message << "It is not possible to register this probe to a new 'tools::Reporter_probe' because it is already "
      28           0 :                 << "registered to an other 'tools::Reporter_probe'.";
      29           0 :         throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());
      30           0 :     }
      31          14 :     this->reporter = reporter;
      32          14 :     this->proxy_register_probe(1, typeid(int64_t), "(us)", 100, std::ios_base::scientific, 3);
      33          14 : }
      34             : 
      35             : void
      36         103 : Probe_latency::_probe(const uint8_t* in, const size_t frame_id)
      37             : {
      38         103 :     auto t_stop = std::chrono::steady_clock::now();
      39         103 :     auto time_duration = (int64_t)std::chrono::duration_cast<std::chrono::microseconds>(t_stop - this->t_start).count();
      40         103 :     this->t_start = t_stop;
      41             : 
      42         236 :     for (size_t f = 0; f < this->get_n_frames(); f++)
      43         133 :         this->proxy_probe((void*)&time_duration, frame_id);
      44         103 : }
      45             : 
      46             : void
      47          14 : Probe_latency::reset()
      48             : {
      49          14 :     this->t_start = std::chrono::steady_clock::now();
      50          14 : }

Generated by: LCOV version 1.14