From 3d0d38195d856b3c1d4161bf29b413abb3cb7ef2 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 30 Apr 2018 17:21:28 +0200 Subject: [PATCH] refactor --- src/instr/instr_paje_types.cpp | 24 +++++++++++------------- src/instr/instr_paje_types.hpp | 2 ++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 3f6c5f467d..aca269a3ff 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -23,6 +23,9 @@ Type::Type(std::string name, std::string alias, std::string color, Type* father) father->children_.insert({alias, this}); XBT_DEBUG("new type %s, child of %s", name_.c_str(), father->get_cname()); } + if (trace_format == simgrid::instr::TraceFormat::Paje) { + stream_ << std::fixed << std::setprecision(TRACE_precision()); + } } Type::~Type() @@ -133,28 +136,23 @@ void Type::logDefinition(e_event_type event_type) { if (trace_format != simgrid::instr::TraceFormat::Paje) return; - std::stringstream stream; XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event_type, TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()) << event_type << " " << get_id(); - stream << " " << father_->get_id() << " " << get_name(); + stream_ << event_type << " " << get_id() << " " << father_->get_id() << " " << get_name(); if (isColored()) - stream << " \"" << color_ << "\""; - XBT_DEBUG("Dump %s", stream.str().c_str()); - stream << std::endl; - fprintf(tracing_file, "%s", stream.str().c_str()); + stream_ << " \"" << color_ << "\""; + XBT_DEBUG("Dump %s", stream_.str().c_str()); + fprintf(tracing_file, "%s\n", stream_.str().c_str()); } void Type::logDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest) { if (trace_format != simgrid::instr::TraceFormat::Paje) return; - std::stringstream stream; XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, PAJE_DefineLinkType, TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_DefineLinkType << " " << get_id(); - stream << " " << father_->get_id() << " " << source->get_id() << " " << dest->get_id() << " " << get_name(); - XBT_DEBUG("Dump %s", stream.str().c_str()); - stream << std::endl; - fprintf(tracing_file, "%s", stream.str().c_str()); + stream_ << PAJE_DefineLinkType << " " << get_id() << " " << father_->get_id() << " " << source->get_id(); + stream_ << " " << dest->get_id() << " " << get_name(); + XBT_DEBUG("Dump %s", stream_.str().c_str()); + fprintf(tracing_file, "%s\n", stream_.str().c_str()); } Type* Type::byName(std::string name) diff --git a/src/instr/instr_paje_types.hpp b/src/instr/instr_paje_types.hpp index 71a08d38cd..75f38b5c99 100644 --- a/src/instr/instr_paje_types.hpp +++ b/src/instr/instr_paje_types.hpp @@ -7,6 +7,7 @@ #define INSTR_PAJE_TYPES_HPP #include "src/instr/instr_private.hpp" +#include #include #include @@ -24,6 +25,7 @@ class Type { public: std::map children_; Container* issuer_ = nullptr; + std::stringstream stream_; Type(std::string name, std::string alias, std::string color, Type* father); virtual ~Type(); -- 2.20.1