Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/simdb/apps/AppManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "simdb/apps/App.hpp"
#include "simdb/pipeline/PipelineManager.hpp"
#include "simdb/sqlite/DatabaseManager.hpp"
#include "simdb/utils/StreamFormatters.hpp"
#include "simdb/utils/ThreadSafeLogger.hpp"

#include <filesystem>
Expand Down Expand Up @@ -765,6 +766,8 @@ class AppManager

~ScopedTimer()
{
[[maybe_unused]] ios_format_saver fmt_saver(std::cout);

auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> dur = end - start_;
auto us = std::chrono::duration_cast<std::chrono::microseconds>(dur).count();
Expand Down
2 changes: 2 additions & 0 deletions include/simdb/pipeline/PollingThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "simdb/Exceptions.hpp"
#include "simdb/pipeline/Runnable.hpp"
#include "simdb/utils/StreamFormatters.hpp"

#include <atomic>
#include <chrono>
Expand Down Expand Up @@ -200,6 +201,7 @@ class PollingThread
runnable->print(std::cout, 4);
}

[[maybe_unused]] ios_format_saver fmt_saver(std::cout);
std::cout << "\n";
std::cout << " Performance report:\n";
std::cout << " Num times run: " << num_times_run_ << "\n";
Expand Down
23 changes: 23 additions & 0 deletions include/simdb/utils/StreamFormatters.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include <iostream>

namespace simdb {

class ios_format_saver
{
public:
explicit ios_format_saver(std::ios& s) :
stream_(s)
{
state_.copyfmt(s);
}

~ios_format_saver() { stream_.copyfmt(state_); }

private:
std::ios& stream_;
std::ios state_{nullptr};
};

} // namespace simdb
3 changes: 3 additions & 0 deletions include/simdb/utils/TickTock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <utility>
#include <vector>

#include "simdb/utils/StreamFormatters.hpp"

namespace simdb::utils {

/*!
Expand Down Expand Up @@ -44,6 +46,7 @@ class SelfProfiler
sorted_avg_times.push_back(method_results.second / method_results.first);
}

[[maybe_unused]] ios_format_saver fmt_saver(std::cout);
std::sort(sorted_avg_times.begin(), sorted_avg_times.end(), std::greater<double>());
for (auto avg_time : sorted_avg_times)
{
Expand Down
Loading