00001 /* Ergo, version 3.7, a program for linear scaling electronic structure 00002 * calculations. 00003 * Copyright (C) 2018 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, 00004 * and Anastasia Kruchinina. 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 * Primary academic reference: 00020 * Ergo: An open-source program for linear-scaling electronic structure 00021 * calculations, 00022 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia 00023 * Kruchinina, 00024 * SoftwareX 7, 107 (2018), 00025 * <http://dx.doi.org/10.1016/j.softx.2018.03.005> 00026 * 00027 * For further information about Ergo, see <http://www.ergoscf.org>. 00028 */ 00029 00038 #ifndef SCF_STATISTICS_HEADER 00039 #define SCF_STATISTICS_HEADER 00040 #include <map> 00041 #include "utilities.h" 00042 00043 struct SCF_timer { 00044 SCF_timer(); 00045 void stop(); 00046 double elapsedTimeCPU_sys; 00047 double elapsedTimeCPU_usr; 00048 double elapsedTimeWall; 00049 private: 00050 double startTimeCPU_sys; 00051 double startTimeCPU_usr; 00052 double startTimeWall; 00053 bool stopped_already; 00054 }; 00055 00056 00057 class SCF_statistics { 00058 typedef std::map<std::string, SCF_timer> TimerMap; 00059 typedef std::map<std::string, double> ValueMap; 00060 public: 00061 void start_timer(std::string identifier); 00062 void stop_timer(std::string identifier); 00063 void add_value(std::string identifier, double value); 00064 void add_values( ValueMap & values_to_add); 00065 void output_mfile(std::string name); 00066 protected: 00067 TimerMap timers; 00068 ValueMap values; 00069 private: 00070 void output_value( std::ofstream & os, std::string id, double value); 00071 00072 }; 00073 00074 00075 00076 00077 #endif 00078