SNABSuite  0.x
Spiking Neural Architecture Benchmark Suite
Public Member Functions | List of all members
SNAB::BenchmarkExec Class Reference

#include <benchmark.hpp>

Public Member Functions

 BenchmarkExec (std::string backend, std::string benchmark="all", size_t bench_index=0)
 

Detailed Description

Class for the consecutive execution of all benchmarks/SNABs registered in the snab_registry.hpp

Definition at line 37 of file benchmark.hpp.

Constructor & Destructor Documentation

SNAB::BenchmarkExec::BenchmarkExec ( std::string  backend,
std::string  benchmark = "all",
size_t  bench_index = 0 
)
inline

Constructor which executes all registered benchmarks and gives the result to std::cout and backend.json

Definition at line 101 of file benchmark.hpp.

103  : m_backend(backend)
104  {
105  auto snab_vec = snab_registry(m_backend, bench_index);
106  for (auto i : snab_vec) {
107  if (i->valid() &&
108  (benchmark == "all" || benchmark == i->snab_name())) {
109  global_logger().info("SNABSuite",
110  "Executing " + i->snab_name());
111  size_t repeat = check_for_repeat(i->get_config());
112  if (repeat == 1) {
113  i->build();
114  i->run();
115  results.push_back({{"model", i->snab_name()},
116  {"timestamp", timestamp()},
117  {"task", bench_index_str[bench_index]},
118  {"results", i->evaluate_json()}});
119  }
120  else {
121  std::vector<cypress::Json> repeat_results;
122  i->build();
123  for (size_t j = 0; j < repeat; j++) {
124  i->run();
125  repeat_results.push_back(i->evaluate_json());
126  }
127  results.push_back(
128  {{"model", i->snab_name()},
129  {"timestamp", timestamp()},
130  {"task", bench_index_str[bench_index]},
131  {"results", merge_repeat_results(repeat_results)}});
132  }
133  }
134  }
135  std::cout << results.dump(4) << std::endl;
136  {
137  std::fstream file;
138  file.open(
139  (backend + "_" + std::to_string(bench_index) + ".json").c_str(),
140  std::fstream::out);
141  if (results.size() > 1) {
142  file << results.dump(4) << std::endl;
143  }
144  else {
145  file << results[0].dump(4) << std::endl;
146  }
147  file.close();
148  }
149  };
std::vector< std::shared_ptr< SNABBase > > snab_registry(std::string backend, size_t bench_index)

The documentation for this class was generated from the following file: