Write a little measure about current execution speed.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
b63f232ebe
commit
863a9d3671
3 changed files with 22 additions and 14 deletions
|
@ -157,11 +157,13 @@ namespace
|
|||
{
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
const auto diff = end - start;
|
||||
const long ms = std::chrono::duration_cast<std::chrono::microseconds>(diff).count();
|
||||
const long us = std::chrono::duration_cast<std::chrono::microseconds>(diff).count();
|
||||
|
||||
if (ms < nExecutionPeriodUsec)
|
||||
g_relativeSpeed = double(us) / double(nExecutionPeriodUsec);
|
||||
|
||||
if (us < nExecutionPeriodUsec)
|
||||
{
|
||||
usleep(nExecutionPeriodUsec - ms);
|
||||
usleep(nExecutionPeriodUsec - us);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,17 +124,6 @@ namespace
|
|||
return result;
|
||||
}
|
||||
|
||||
void output(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
WINDOW * win = frame->getBuffer();
|
||||
|
||||
vwprintw(win, fmt, args);
|
||||
wrefresh(win);
|
||||
}
|
||||
|
||||
void VideoUpdateFlash()
|
||||
{
|
||||
static UINT nTextFlashCnt = 0;
|
||||
|
@ -161,6 +150,19 @@ namespace
|
|||
|
||||
}
|
||||
|
||||
double g_relativeSpeed = 0;
|
||||
|
||||
void output(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
WINDOW * win = frame->getBuffer();
|
||||
|
||||
vwprintw(win, fmt, args);
|
||||
wrefresh(win);
|
||||
}
|
||||
|
||||
bool Update40ColCell (int x, int y, int xpixel, int ypixel, int offset)
|
||||
{
|
||||
frame->init(40);
|
||||
|
@ -253,6 +255,7 @@ void FrameRefresh()
|
|||
// approximate
|
||||
const double frequency = 0.5 * alpha * F;
|
||||
mvwprintw(status, 1, 20, "%5.fHz", frequency);
|
||||
mvwprintw(status, 2, 20, "%5.1f%%", 100 * g_relativeSpeed);
|
||||
|
||||
wrefresh(status);
|
||||
}
|
||||
|
|
|
@ -5,3 +5,6 @@ void ProcessInput();
|
|||
void VideoInitialize();
|
||||
void VideoUninitialize();
|
||||
void VideoRedrawScreen();
|
||||
|
||||
void output(const char *fmt, ...);
|
||||
extern double g_relativeSpeed;
|
||||
|
|
Loading…
Add table
Reference in a new issue