Created
February 17, 2026 21:42
-
-
Save jdbrice/bdfee0553329996d4e8a1ffe10762743 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| StMemStat stm; | |
| void printMEM(){ | |
| stm.PrintMem(); | |
| } | |
| #include <fstream> | |
| #include "StMemStat.h" // Ensure this is available and correctly included | |
| #ifndef __CINT__ | |
| #include <chrono> | |
| class MemoryLogger { | |
| public: | |
| MemoryLogger(const std::string& filename) | |
| : start_time_(std::chrono::steady_clock::now()), log_file_(filename, std::ios::app) { | |
| if (log_file_.tellp() == 0) { | |
| log_file_ << "# Time(s)\tProgSize(MB)\n"; | |
| } | |
| } | |
| void log(const std::string& comment = "") { | |
| auto now = std::chrono::steady_clock::now(); | |
| std::chrono::duration<double> elapsed = now - start_time_; | |
| double progSizeMB = StMemStat::ProgSize(); // assuming kB | |
| log_file_ << std::fixed << std::setprecision(6) | |
| << elapsed.count() << "\t" << progSizeMB; | |
| if (!comment.empty()) { | |
| log_file_ << "\t# " << comment; | |
| } | |
| log_file_ << "\n"; | |
| } | |
| private: | |
| std::chrono::steady_clock::time_point start_time_; | |
| std::ofstream log_file_; | |
| }; | |
| MemoryLogger MemLogger("mem_log.txt"); | |
| #endif // CINT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment