10 #define STR2WSTR0(s) L ## s 11 #define STR2WSTR(s) STR2WSTR0(s) 18 #define ASSERT(x) ASSERT0(x, \ 19 L"Assertion failed: " #x, \ 20 STR2WSTR(__FUNCSIG__), __FILEW__, __LINE__) 22 #define ASSERT0(x, msg, sig, file, line) do { \ 24 yappy::debug::writeLine(msg); \ 25 yappy::debug::writef(L"%s (%s: %d)", sig, file, line); \ 52 void write(
const wchar_t *
str,
bool newline =
false) noexcept;
57 inline void write(
const char *str,
bool newline =
false) noexcept
64 inline void writeLine(
const wchar_t *str = L
"") noexcept
79 void writef(
const wchar_t *fmt, ...) noexcept;
84 void writef(
const char *fmt, ...) noexcept;
107 BOOL b = ::QueryPerformanceCounter(&m_begin);
116 LARGE_INTEGER end, freq;
117 b = ::QueryPerformanceCounter(&end);
119 b = ::QueryPerformanceFrequency(&freq);
121 double sec =
static_cast<double>(end.QuadPart - m_begin.QuadPart) / freq.QuadPart;
122 writef(L
"%s: %.3f us", m_msg, sec * 1e6);
125 const wchar_t *m_msg;
126 LARGE_INTEGER m_begin;
137 void initialize(
size_t bufsize = 1024 * 1024);
bool enableDebugOutput() noexcept
Enables writing to OutputDebugString().
void write(const wchar_t *str, bool newline) noexcept
Write debug string.
Stop watch utility for performance measurement.
void writef(const wchar_t *fmt,...) noexcept
Write debug message using format string like printf.
~StopWatch()
Destructor. Stop the timer.
void initialize(size_t bufsize)
Initialize trace buffer.
void shutdownDebugOutput() noexcept
Flush buffers and free resources.
StopWatch(const wchar_t *msg)
Constructor. Starts the timer.
void writeLine(const wchar_t *str=L"") noexcept
Write debug string and new line.
void output()
Output to a temporary file and open it with notepad.
char msg[LINE_DATA_SIZE-sizeof(LARGE_INTEGER)-sizeof(uint32_t)]
bool enableFileOutput(const wchar_t *fileName) noexcept
Enables writing to a file.
std::unique_ptr< wchar_t[]> utf82wc(const char *in)
UTF-8 to wide char.
bool enableConsoleOutput() noexcept
Shows a console window and enables writing to it.
void checkWin32Result(bool cond, const std::string &msg)
void writef_nonl(const wchar_t *fmt,...) noexcept
Write debug message using format string like printf. (No new line)