Commit f07057f1 authored by Matthieu Dorier's avatar Matthieu Dorier

added methods to print statistics

parent 9882df6e
......@@ -6,6 +6,8 @@
#ifndef __HEPNOS_STATISTICS_H
#define __HEPNOS_STATISTICS_H
#include <ostream>
namespace hepnos {
/**
......@@ -41,4 +43,15 @@ struct Statistics {
}
template<typename Number, typename Double=double>
std::ostream& operator<<(std::ostream& os, const hepnos::Statistics<Number, Double>& stats)
{
return os << "{ \"num\" : " << stats.num
<< ", \"max\" : " << stats.max
<< ", \"min\" : " << stats.min
<< ", \"avg\" : " << stats.avg
<< ", \"var\" : " << stats.var
<< " }";
}
#endif
......@@ -6,6 +6,7 @@
#ifndef __HEPNOS_WRITE_BATCH_H
#define __HEPNOS_WRITE_BATCH_H
#include <ostream>
#include <memory>
#include <string>
#include <vector>
......@@ -130,4 +131,6 @@ class WriteBatch {
}
std::ostream& operator<<(std::ostream& os, const hepnos::WriteBatchStatistics& stats);
#endif
......@@ -38,9 +38,6 @@ class AsyncEngineImpl {
for(size_t i=0; i < num_threads; i++) {
m_xstreams.push_back(tl::xstream::create(tl::scheduler::predef::deflt, m_pool));
}
for(auto& es : m_xstreams) {
es->start();
}
} else {
auto current_es = tl::xstream::self();
auto pools = current_es.get_main_pools(1);
......@@ -125,19 +122,14 @@ class AsyncEngineImpl {
}
void wait() {
// join the current set of ES
// join the set of ES
for(auto& es : m_xstreams) {
es->join();
}
// create a new set of ES
std::vector<tl::managed<tl::xstream>> new_es;
for(unsigned i=0; i < m_xstreams.size(); i++) {
new_es.push_back(tl::xstream::create(tl::scheduler::predef::deflt, m_pool));
}
// replace old es
m_xstreams = std::move(new_es);
// starting new ES
for(auto& es : m_xstreams) es->start();
// revive the ES
for(auto& es : m_xstreams) {
es->revive();
}
}
};
......
......@@ -50,3 +50,11 @@ void WriteBatch::collectStatistics(WriteBatchStatistics& stats) const {
}
}
std::ostream& operator<<(std::ostream& os, const hepnos::WriteBatchStatistics& stats)
{
return os << "{ \"batch_size\" : " << stats.batch_sizes
<< ", \"key_sizes\" : " << stats.key_sizes
<< ", \"value_size\" : " << stats.value_sizes
<< " }";
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment