Skip to content

Commit

Permalink
more efficient formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob authored and Jacob committed Nov 9, 2023
1 parent 2b5d631 commit e9f895c
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 60 deletions.
15 changes: 14 additions & 1 deletion include/ioh/common/clutchlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -765,12 +765,18 @@ class clutchlog

// Equivalent class with empty methods, will be optimized out
// while allowing to actually have calls implemented without WITH_CLUTCHLOG guards.
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreturn-type"
#endif
class clutchlog
{
public:
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4716)
static clutchlog& logger() { }
#endif
enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
class fmt {
public:
Expand Down Expand Up @@ -828,7 +834,7 @@ class clutchlog
void file(std::string) {}
void func(std::string) {}
void line(std::string) {}

#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
void location(
Expand All @@ -838,9 +844,14 @@ class clutchlog
)
{ }
#pragma GCC diagnostic pop
#endif
void style(level, fmt) { }
fmt style(level) const { }
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4716)
level level_of(const std::string) { }
#endif
public:
std::string replace(
const std::string&,
Expand Down Expand Up @@ -890,7 +901,9 @@ class clutchlog
) const
{ }
};
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif
#endif // WITH_CLUTCHLOG

#endif // __CLUTCHLOG_H__
4 changes: 4 additions & 0 deletions include/ioh/common/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,11 @@ namespace ioh::common::file
}
~async_buf()
{
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4834)
std::unique_lock<std::mutex>(this->mutex), (this->done = true);
#endif
this->condition.notify_one();
this->thread.join();
}
Expand Down
21 changes: 12 additions & 9 deletions include/ioh/logger/flatfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,26 @@ namespace ioh::logger
out_->write(eol_);
requires_header_ = false;
}

IOH_DBG(xdebug, "print problem meta data")
out_->write(current_meta_data_);
std::string to_write = current_meta_data_;
auto inserter = std::back_inserter(to_write);

IOH_DBG(xdebug, "print watched properties")

for (auto p = properties_vector_.begin(); p != properties_vector_.end();){
auto str = p->get().call_to_string(log_info, nan_);
if (++p != properties_vector_.end())
str += sep_;
out_->write(str);
p->get().call_to_string(to_write, log_info, nan_);
if (++p != properties_vector_.end())
fmt::format_to(inserter, "{}", sep_);
}

if (store_positions_)
out_->write(sep_ + format("{:f}", fmt::join(log_info.x, sep_)));

out_->write(eol_);
{
fmt::format_to(inserter, "{}", sep_);
fmt::format_to(inserter, "{:f}", fmt::join(log_info.x, sep_));
}
fmt::format_to(inserter, "{}", eol_);
out_->write(to_write);
}

//! Accessor for output directory
Expand Down
Loading

0 comments on commit e9f895c

Please sign in to comment.