Bladeren bron

Adds memory usage to printout and debug outputs for values

Caleb Fangmeier 7 jaren geleden
bovenliggende
commit
bcde82f005
2 gewijzigde bestanden met toevoegingen van 9 en 1 verwijderingen
  1. 7 1
      dataset.hpp
  2. 2 0
      value.hpp

+ 7 - 1
dataset.hpp

@@ -33,6 +33,7 @@
 #include <iostream>
 #include "value.hpp"
 #include "container.hpp"
+#include "memtrack.hpp"
 #include "datafile.hpp"
 #include "log.hpp"
 
@@ -95,8 +96,13 @@ class DataSet{
             if (!silent) std::cout << std::endl;
             while( load_next() ){
                 current_event = get_current_event();
-                if (!silent) std::cout << "\rprocessing event: " << current_event+1 << "/" << events
+                if (!silent){
+                    size_t m_used = getCurrentRSS() / 1024 / 1024;
+                    size_t m_peak = getPeakRSS() / 1024 / 1024;
+                    std::cout << "\rprocessing event: " << current_event+1 << "/" << events
+                    << ", " << m_used << "/" << m_peak << "MB used/peak"
                     << " of file: " << get_current_file().filename << std::flush;
+                }
                 GenValue::reset();
                 for(auto con : containers){
                     DEBUG("Filling container " << con.first << ".");

+ 2 - 0
value.hpp

@@ -253,6 +253,7 @@ class Function<R(ArgTypes...)> : public GenFunction {
         ~Function() { }
 
         R operator()(ArgTypes ...args){
+            DEBUG("Calculating Function: " << this->get_name());
             return f(args...);
         }
 
@@ -516,6 +517,7 @@ class DerivedValue : public Value<T>{
         }
 
         T& get_value(){
+            DEBUG("Getting Value: " << this->get_name());
             if (!this->value_valid){
                 update_value();
                 this->value_valid = true;