votca 2026-dev
Loading...
Searching...
No Matches
dfttimings.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2026 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20// Third party includes
21#include <boost/format.hpp>
22
23// Local VOTCA includes
25
26namespace votca {
27namespace xtp {
28
30 const std::string& title) const {
31 const double total = Elapsed();
32 double accounted = 0.0;
33 XTP_LOG(level, log) << " " << title << " (wall clock)" << std::flush;
34 XTP_LOG(level, log) << (boost::format(" %-38s %7s %11s %10s %6s") % "part" %
35 "calls" % "time [s]" % "per call" % "%")
36 .str()
37 << std::flush;
38 for (const Entry& e : entries_) {
39 accounted += e.seconds;
40 XTP_LOG(level, log) << (boost::format(" %-38s %7d %11.2f %10.3f %6.1f") %
41 e.name % e.calls % e.seconds %
42 (e.seconds / double(e.calls)) %
43 (total > 0 ? 100.0 * e.seconds / total : 0.0))
44 .str()
45 << std::flush;
46 }
47 XTP_LOG(level, log) << (boost::format(" %-38s %7s %11.2f %10s %6.1f") %
48 "not itemised" % "" % (total - accounted) % "" %
49 (total > 0 ? 100.0 * (total - accounted) / total
50 : 0.0))
51 .str()
52 << std::flush;
53 XTP_LOG(level, log)
54 << (boost::format(" %-38s %7s %11.2f") % "total" % "" % total).str()
55 << std::flush;
56}
57
58std::string DFTTimings::Format() const {
59 std::string line;
60 for (const Entry& e : entries_) {
61 if (!line.empty()) {
62 line += ", ";
63 }
64 line += (boost::format("%s %.2f s") % e.name % e.seconds).str();
65 }
66 return line;
67}
68
70 std::ifstream status("/proc/self/status");
71 if (!status.is_open()) {
72 return -1.0;
73 }
74 const std::string key = peak ? "VmHWM:" : "VmRSS:";
75 std::string word;
76 while (status >> word) {
77 if (word == key) {
78 double kb = 0.0;
79 status >> kb;
80 return kb / (1024.0 * 1024.0);
81 }
82 }
83 return -1.0;
84}
85
86} // namespace xtp
87} // namespace votca
std::vector< Entry > entries_
Definition dfttimings.h:124
double Elapsed() const
Definition dfttimings.h:91
void Report(Logger &log, Log::Level level, const std::string &title="DFT timing summary") const
Table of all entries with their share of the time since Reset().
Definition dfttimings.cc:29
static double ResidentMemoryGB(bool peak)
Definition dfttimings.cc:69
std::string Format() const
The entries on one line, "name 1.23 s, name 4.56 s".
Definition dfttimings.cc:58
Logger is used for thread-safe output of messages.
Definition logger.h:164
#define XTP_LOG(level, log)
Definition logger.h:40
Charge transport classes.
Definition ERIs.h:28
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Level
be loud and noisy
Definition globals.h:28