#include #include #include "minimal_repr.hh" #include "TFile.h" ClassImp(A); ClassImp(B); A make_a(const size_t n_str) { std::map map; for(size_t i = 0; i < n_str; ++i) { TString key = "TString"; key += TString::Itoa(i, 10); map[key] = 0.5; } return A{TString{"name"}, map}; } B make_b(const size_t n_vec, const size_t n_str) { auto vec = std::vector>(n_vec, {0.4, 0.7}); std::map> map; for(size_t i = 0; i < n_str; ++i) { TString key = "TString"; key += TString::Itoa(i, 10); map[key] = {make_a(n_str), make_a(n_str)}; } auto big_vec = std::vector>>(n_vec, map); auto vec_str = std::vector(n_str, TString("strings")); return B{vec, std::move(big_vec), std::move(vec_str)}; } void timing(const size_t n_vec, const size_t n_str) { TFile of("test.root", "RECREATE"); B b = make_b(n_vec, n_str); std::cout << "Writing..." << std::endl; auto start = std::chrono::high_resolution_clock::now(); of.WriteObject(&b, "b"); auto stop = std::chrono::system_clock::now(); of.Close(); std::cout << "Elapsed time for (" << n_vec << ", " << n_str << "): " << std::chrono::duration_cast(stop - start).count() << " ms" << std::endl; } int main() { const size_t n_vec = 152; const size_t n_str = 299; timing(10, 10); timing(20, 10); timing(30, 10); timing(40, 10); timing(50, 10); return 0; }