artdaq  v3_12_02
TransferTest.hh
1 #ifndef ARTDAQ_TEST_DAQRATE_TRANSFERTEST_HH
2 #define ARTDAQ_TEST_DAQRATE_TRANSFERTEST_HH
3 
4 #include <chrono>
5 #include <cmath>
6 #include <string>
7 #include <utility> // std::pair<>
8 #include <vector>
9 
10 #include "fhiclcpp/ParameterSet.h"
11 
12 namespace artdaq {
17 {
18 public:
36  explicit TransferTest(fhicl::ParameterSet psi);
37 
42  int runTest();
43 
48  int returnCode() { return return_code_; }
49 
50 private:
51  std::pair<size_t, double> do_sending(int thread_index);
52 
53  std::pair<size_t, double> do_receiving();
54 
55  // Helper functions
56  const std::vector<std::string> suffixes{" B", " KB", " MB", " GB", " TB"};
57 
58  std::string formatBytes(double bytes, size_t suffixIndex = 0);
59 
60  int senders_;
61  int receivers_;
62  int sending_threads_;
63  int sends_each_sender_;
64  int receives_each_receiver_; // Should be sends_each_sender * sending_threads * sending_ranks / receiving_ranks
65  int buffer_count_;
66  int error_count_max_;
67  size_t fragment_size_;
68  std::chrono::steady_clock::time_point start_time_;
69  fhicl::ParameterSet ps_;
70  bool validate_mode_;
71  int partition_number_;
72 
73  int return_code_{0};
74 };
75 
76 inline std::string TransferTest::formatBytes(double bytes, size_t suffixIndex)
77 {
78  auto b = fabs(bytes);
79 
80  if (b > 1024.0 && suffixIndex < suffixes.size())
81  {
82  return formatBytes(bytes / 1024.0, suffixIndex + 1);
83  }
84 
85  return std::to_string(bytes) + suffixes[suffixIndex];
86 }
87 } // namespace artdaq
88 #endif // ARTDAQ_TEST_DAQRATE_TRANSFERTEST_HH
int runTest()
Run the test as configured.
int returnCode()
Get the result of the test.
Definition: TransferTest.hh:48
TransferTest(fhicl::ParameterSet psi)
TransferTest Constructor.
Definition: TransferTest.cc:12
Test a set of TransferInterface plugins.
Definition: TransferTest.hh:16