#include <memory>
#include <algorithm>
#include <cassert>
-#include <iomanip>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
using namespace std;
-ostream& operator<<(ostream& out, const formatBytes data)
-{
- if (data.m_bytes < 1000) {
- // no fancy formatting for plain byte values, esp. no .00 factions
- return out << data.m_bytes << 'B';
- }
-
- static const auto units = {
- "B",
- "KB",
- "MB",
- "GB",
- "TB"
- };
- auto unit = units.begin();
- size_t i = 0;
- double bytes = data.m_bytes;
- while (i < units.size() - 1 && bytes > 1000.) {
- bytes /= 1000.;
- ++i;
- ++unit;
- }
- return out << fixed << setprecision(2) << bytes << *unit;
-}
-
namespace {
template<typename Base>
#include <unordered_map>
#include <map>
-class formatBytes
-{
-public:
- formatBytes(size_t bytes)
- : m_bytes(bytes)
- {
- }
-
- friend std::ostream& operator<<(std::ostream& out, const formatBytes data);
-
-private:
- size_t m_bytes;
-};
-
// sadly, C++ doesn't yet have opaque typedefs
template<typename Base>
struct Index
#include "model.h"
#include <QDebug>
+#include <QTextStream>
+#include <KFormat>
#include <ThreadWeaver/ThreadWeaver>
#include <sstream>
namespace {
QString generateSummary(const AccumulatedTraceData& data)
{
- stringstream stream;
+ QString ret;
+ KFormat format;
+ QTextStream stream(&ret);
const double totalTimeS = 0.001 * data.totalTime;
stream << "<qt>"
- << "<strong>total runtime</strong>: " << fixed << totalTimeS << "s.<br/>"
- << "<strong>bytes allocated in total</strong> (ignoring deallocations): " << formatBytes(data.totalAllocated)
- << " (" << formatBytes(data.totalAllocated / totalTimeS) << "/s)<br/>"
+ << "<strong>total runtime</strong>: " << totalTimeS << "s.<br/>"
+ << "<strong>bytes allocated in total</strong> (ignoring deallocations): " << format.formatByteSize(data.totalAllocated, 2)
+ << " (" << format.formatByteSize(data.totalAllocated / totalTimeS) << "/s)<br/>"
<< "<strong>calls to allocation functions</strong>: " << data.totalAllocations
<< " (" << size_t(data.totalAllocations / totalTimeS) << "/s)<br/>"
- << "<strong>peak heap memory consumption</strong>: " << formatBytes(data.peak) << "<br/>"
- << "<strong>total memory leaked</strong>: " << formatBytes(data.leaked) << "<br/>";
+ << "<strong>peak heap memory consumption</strong>: " << format.formatByteSize(data.peak) << "<br/>"
+ << "<strong>total memory leaked</strong>: " << format.formatByteSize(data.leaked) << "<br/>";
stream << "</qt>";
- return QString::fromStdString(stream.str());
+ return ret;
}
int parentRow(const QModelIndex& child)
#include "accumulatedtracedata.h"
#include <iostream>
+#include <iomanip>
#include "config.h"
using namespace std;
namespace po = boost::program_options;
+namespace {
+
+class formatBytes
+{
+public:
+ formatBytes(size_t bytes)
+ : m_bytes(bytes)
+ {
+ }
+
+ friend std::ostream& operator<<(std::ostream& out, const formatBytes data);
+
+private:
+ size_t m_bytes;
+};
+
+ostream& operator<<(ostream& out, const formatBytes data)
+{
+ if (data.m_bytes < 1000) {
+ // no fancy formatting for plain byte values, esp. no .00 factions
+ return out << data.m_bytes << 'B';
+ }
+
+ static const auto units = {
+ "B",
+ "KB",
+ "MB",
+ "GB",
+ "TB"
+ };
+ auto unit = units.begin();
+ size_t i = 0;
+ double bytes = data.m_bytes;
+ while (i < units.size() - 1 && bytes > 1000.) {
+ bytes /= 1000.;
+ ++i;
+ ++unit;
+ }
+ return out << fixed << setprecision(2) << bytes << *unit;
+}
+
struct Printer final : public AccumulatedTraceData
{
template<typename T, typename LabelPrinter, typename SubLabelPrinter>
size_t lastMassifPeak = 0;
vector<Allocation> massifAllocations;
};
+}
int main(int argc, char** argv)
{