Loading...
Searching...
No Matches
Timer.h
Go to the documentation of this file.
#ifndef HL_TIMER_H
#define HL_TIMER_H
#include <chrono>
#include <set>
#include <string>
#include <vector>
#include "ASLog.h"
namespace Halide {
namespace Internal {
namespace Autoscheduler {
using Clock = std::chrono::high_resolution_clock;
struct ScopedTimer {
std::chrono::time_point<Clock> start = Clock::now();
std::string msg;
explicit ScopedTimer(const std::string &msg)
: msg{msg} {
aslog(0) << "Start: " << msg << "\n";
}
~ScopedTimer() {
auto duration = Clock::now() - start;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
aslog(0) << "Duration (ms): " << msg << " = " << ms << "\n";
}
};
struct Timer {
std::chrono::time_point<Clock> start = Clock::now();
Timer() = default;
void restart() {
start = Clock::now();
}
std::chrono::duration<double> elapsed() const {
return Clock::now() - start;
}
};
} // namespace Autoscheduler
} // namespace Internal
} // namespace Halide
#endif // HL_TIMER_H
ASLog.h
Halide::Internal::aslog
Definition ASLog.h:16
Halide::Internal::Autoscheduler
Definition AutoSchedule.h:10
Halide::Internal::Autoscheduler::Clock
std::chrono::high_resolution_clock Clock
Definition Timer.h:15
Halide::Internal
Definition AbstractGenerator.h:24
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::Internal::Autoscheduler::ScopedTimer::ScopedTimer
ScopedTimer(const std::string &msg)
Definition Timer.h:21
Halide::Internal::Autoscheduler::ScopedTimer::msg
std::string msg
Definition Timer.h:19
Halide::Internal::Autoscheduler::ScopedTimer::start
std::chrono::time_point< Clock > start
Definition Timer.h:18
Halide::Internal::Autoscheduler::ScopedTimer::~ScopedTimer
~ScopedTimer()
Definition Timer.h:26
Halide::Internal::Autoscheduler::Timer::restart
void restart()
Definition Timer.h:38
Halide::Internal::Autoscheduler::Timer::start
std::chrono::time_point< Clock > start
Definition Timer.h:34
Halide::Internal::Autoscheduler::Timer::Timer
Timer()=default
Halide::Internal::Autoscheduler::Timer::elapsed
std::chrono::duration< double > elapsed() const
Definition Timer.h:42