From a64a287d9d534a31e5b49dc99be038f9c0b7c6af Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 10 May 2022 17:11:09 +0200 Subject: [PATCH] Prefer \n over std::endl (no need to flush at each end-of-line). --- src/instr/instr_config.cpp | 18 +-- src/instr/instr_paje_events.cpp | 2 +- src/instr/instr_paje_header.cpp | 250 ++++++++++++++++---------------- src/instr/instr_platform.cpp | 18 +-- 4 files changed, 144 insertions(+), 144 deletions(-) diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index 5a6075f4d7..e989fd457e 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -240,7 +240,7 @@ static void on_container_creation_paje(const Container& c) stream << "rank-" << stoi(c.get_name().substr(5)) - 1 << "\""; XBT_DEBUG("Dump %s", stream.str().c_str()); - tracing_file << stream.str() << std::endl; + tracing_file << stream.str() << '\n'; } static void on_container_destruction_paje(const Container& c) @@ -256,7 +256,7 @@ static void on_container_destruction_paje(const Container& c) stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::DestroyContainer << " "; stream << timestamp << " " << c.get_type()->get_id() << " " << c.get_id(); XBT_DEBUG("Dump %s", stream.str().c_str()); - tracing_file << stream.str() << std::endl; + tracing_file << stream.str() << '\n'; } } @@ -283,7 +283,7 @@ static void on_container_creation_ti(const Container& c) #endif ti_unique_file = new std::ofstream(filename.c_str(), std::ofstream::out); xbt_assert(not ti_unique_file->fail(), "Tracefile %s could not be opened for writing", filename.c_str()); - tracing_file << filename << std::endl; + tracing_file << filename << '\n'; } tracing_files.insert({&c, ti_unique_file}); } @@ -308,7 +308,7 @@ static void on_entity_value_creation(const EntityValue& value) if (not value.get_color().empty()) stream << " \"" << value.get_color() << "\""; XBT_DEBUG("Dump %s", stream.str().c_str()); - tracing_file << stream.str() << std::endl; + tracing_file << stream.str() << '\n'; } static void on_event_creation(PajeEvent& event) @@ -323,13 +323,13 @@ static void on_event_creation(PajeEvent& event) static void on_event_destruction(const PajeEvent& event) { XBT_DEBUG("Dump %s", event.stream_.str().c_str()); - tracing_file << event.stream_.str() << std::endl; + tracing_file << event.stream_.str() << '\n'; } static void on_state_event_destruction(const StateEvent& event) { if (event.has_extra()) - *tracing_files.at(event.get_container()) << event.stream_.str() << std::endl; + *tracing_files.at(event.get_container()) << event.stream_.str() << '\n'; } static void on_type_creation(const Type& type, PajeEventType event_type) @@ -344,7 +344,7 @@ static void on_type_creation(const Type& type, PajeEventType event_type) if (type.is_colored()) stream << " \"" << type.get_color() << "\""; XBT_DEBUG("Dump %s", stream.str().c_str()); - tracing_file << stream.str() << std::endl; + tracing_file << stream.str() << '\n'; } static void on_link_type_creation(const Type& type, const Type& source, const Type& dest) @@ -355,7 +355,7 @@ static void on_link_type_creation(const Type& type, const Type& source, const Ty stream << PajeEventType::DefineLinkType << " " << type.get_id() << " " << type.get_parent()->get_id(); stream << " " << source.get_id() << " " << dest.get_id() << " " << type.get_name(); XBT_DEBUG("Dump %s", stream.str().c_str()); - tracing_file << stream.str() << std::endl; + tracing_file << stream.str() << '\n'; } static void on_simulation_start() @@ -395,7 +395,7 @@ static void on_simulation_start() /* output one line comment */ if (auto comment = simgrid::config::get_value("tracing/comment"); not comment.empty()) - tracing_file << "# " << comment << std::endl; + tracing_file << "# " << comment << '\n'; /* output comment file */ paje::dump_comment_file(config::get_value(OPT_TRACING_COMMENT_FILE)); diff --git a/src/instr/instr_paje_events.cpp b/src/instr/instr_paje_events.cpp index c66ef1edbe..e4bfcb3019 100644 --- a/src/instr/instr_paje_events.cpp +++ b/src/instr/instr_paje_events.cpp @@ -76,7 +76,7 @@ void StateEvent::print() } #if HAVE_SMPI if (smpi_cfg_trace_call_location()) - stream_ << container_name << " location " << filename << " " << linenumber << std::endl ; + stream_ << container_name << " location " << filename << " " << linenumber << '\n'; #endif stream_ << container_name << " " << extra_->print(); } else { diff --git a/src/instr/instr_paje_header.cpp b/src/instr/instr_paje_header.cpp index 725117b58c..44092c26dc 100644 --- a/src/instr/instr_paje_header.cpp +++ b/src/instr/instr_paje_header.cpp @@ -16,12 +16,12 @@ namespace simgrid::instr::paje { void dump_generator_version() { tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR - << "." << SIMGRID_VERSION_PATCH << std::endl; + << "." << SIMGRID_VERSION_PATCH << '\n'; tracing_file << "#["; for (auto const& str : simgrid::xbt::cmdline) { tracing_file << str << " "; } - tracing_file << "]" << std::endl; + tracing_file << "]\n"; } void dump_comment_file(const std::string& filename) @@ -45,153 +45,153 @@ void dump_comment_file(const std::string& filename) void dump_header(bool basic, bool display_sizes) { // Types - tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << std::endl; - tracing_file << "% Alias string" << std::endl; + tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << '\n'; + tracing_file << "% Alias string\n"; if (basic) - tracing_file << "% ContainerType string" << std::endl; + tracing_file << "% ContainerType string\n"; else - tracing_file << "% Type string" << std::endl; - - tracing_file << "% Name string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << std::endl; - tracing_file << "% Alias string" << std::endl; - tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl; - tracing_file << "% Name string" << std::endl; - tracing_file << "% Color color" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << std::endl; - tracing_file << "% Alias string" << std::endl; - tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl; - tracing_file << "% Name string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << std::endl; - tracing_file << "% Alias string" << std::endl; - tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl; - tracing_file << "% Name string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << std::endl; - tracing_file << "% Alias string" << std::endl; - tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl; - tracing_file << "% " << (basic ? "Source" : "Start") << "ContainerType string" << std::endl; - tracing_file << "% " << (basic ? "Dest" : "End") << "ContainerType string" << std::endl; - tracing_file << "% Name string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "% Type string\n"; + + tracing_file << "% Name string\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << '\n'; + tracing_file << "% Alias string\n"; + tracing_file << "% " << (basic ? "Container" : "") << "Type string\n"; + tracing_file << "% Name string\n"; + tracing_file << "% Color color\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << '\n'; + tracing_file << "% Alias string\n"; + tracing_file << "% " << (basic ? "Container" : "") << "Type string\n"; + tracing_file << "% Name string\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << '\n'; + tracing_file << "% Alias string\n"; + tracing_file << "% " << (basic ? "Container" : "") << "Type string\n"; + tracing_file << "% Name string\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << '\n'; + tracing_file << "% Alias string\n"; + tracing_file << "% " << (basic ? "Container" : "") << "Type string\n"; + tracing_file << "% " << (basic ? "Source" : "Start") << "ContainerType string\n"; + tracing_file << "% " << (basic ? "Dest" : "End") << "ContainerType string\n"; + tracing_file << "% Name string\n"; + tracing_file << "%EndEventDef\n"; // EntityValue - tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << std::endl; - tracing_file << "% Alias string" << std::endl; - tracing_file << "% " << (basic ? "Entity" : "") << "Type string" << std::endl; - tracing_file << "% Name string" << std::endl; - tracing_file << "% Color color" << std::endl; - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << '\n'; + tracing_file << "% Alias string\n"; + tracing_file << "% " << (basic ? "Entity" : "") << "Type string\n"; + tracing_file << "% Name string\n"; + tracing_file << "% Color color\n"; + tracing_file << "%EndEventDef\n"; // Container - tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Alias string" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Name string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Name string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Alias string\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Name string\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Name string\n"; + tracing_file << "%EndEventDef\n"; // Variable - tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Value double" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Value double" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Value double" << std::endl; - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Value double\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Value double\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Value double\n"; + tracing_file << "%EndEventDef\n"; // State - tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Value string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Value string" << std::endl; + tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Value string\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Value string\n"; if (display_sizes) - tracing_file << "% Size int" << std::endl; + tracing_file << "% Size int\n"; #if HAVE_SMPI if (smpi_cfg_trace_call_location()) { /* paje currently (May 2016) uses "Filename" and "Linenumber" as reserved words. We cannot use them... */ - tracing_file << "% Fname string" << std::endl; - tracing_file << "% Lnumber int" << std::endl; + tracing_file << "% Fname string\n"; + tracing_file << "% Lnumber int\n"; } #endif - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "%EndEventDef\n"; - tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "%EndEventDef\n"; if (not basic) { - tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "%EndEventDef\n"; } // Link - tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Value string" << std::endl; - tracing_file << "% " << (basic ? "Source" : "Start") << "Container string" << std::endl; - tracing_file << "% Key string" << std::endl; + tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Value string\n"; + tracing_file << "% " << (basic ? "Source" : "Start") << "Container string\n"; + tracing_file << "% Key string\n"; if (display_sizes) - tracing_file << "% Size int" << std::endl; - tracing_file << "%EndEventDef" << std::endl; - - tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Value string" << std::endl; - tracing_file << "% " << (basic ? "Dest" : "End") << "Container string" << std::endl; - tracing_file << "% Key string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "% Size int\n"; + tracing_file << "%EndEventDef\n"; + + tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Value string\n"; + tracing_file << "% " << (basic ? "Dest" : "End") << "Container string\n"; + tracing_file << "% Key string\n"; + tracing_file << "%EndEventDef\n"; // Event - tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << std::endl; - tracing_file << "% Time date" << std::endl; - tracing_file << "% Type string" << std::endl; - tracing_file << "% Container string" << std::endl; - tracing_file << "% Value string" << std::endl; - tracing_file << "%EndEventDef" << std::endl; + tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << '\n'; + tracing_file << "% Time date\n"; + tracing_file << "% Type string\n"; + tracing_file << "% Container string\n"; + tracing_file << "% Value string\n"; + tracing_file << "%EndEventDef\n"; } } // namespace simgrid::instr::paje diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index 5594252798..3d14cfe7a7 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -222,27 +222,27 @@ void platform_graph_export_graphviz(const std::string& output_filename) xbt_assert(not fs.fail(), "Failed to open %s", output_filename.c_str()); if (g->directed) - fs << "digraph test {" << std::endl; + fs << "digraph test {\n"; else - fs << "graph test {" << std::endl; + fs << "graph test {\n"; - fs << " graph [overlap=scale]" << std::endl; + fs << " graph [overlap=scale]\n"; - fs << " node [shape=box, style=filled]" << std::endl; - fs << " node [width=.3, height=.3, style=filled, color=skyblue]" << std::endl << std::endl; + fs << " node [shape=box, style=filled]\n"; + fs << " node [width=.3, height=.3, style=filled, color=skyblue]\n\n"; for (auto const& [node, _] : nodes) - fs << " \"" << node << "\";" << std::endl; + fs << " \"" << node << "\";\n"; for (auto const& [_, edge] : edges) { const char* src_s = static_cast(edge->src->data); const char* dst_s = static_cast(edge->dst->data); if (g->directed) - fs << " \"" << src_s << "\" -> \"" << dst_s << "\";" << std::endl; + fs << " \"" << src_s << "\" -> \"" << dst_s << "\";\n"; else - fs << " \"" << src_s << "\" -- \"" << dst_s << "\";" << std::endl; + fs << " \"" << src_s << "\" -- \"" << dst_s << "\";\n"; } - fs << "}" << std::endl; + fs << "}\n"; fs.close(); xbt_graph_free_graph(g, xbt_free_f, xbt_free_f, nullptr); -- 2.20.1