Skip to content

Commit

Permalink
Fix benchmarks in appveyor
Browse files Browse the repository at this point in the history
  • Loading branch information
BigRedEye committed Aug 13, 2018
1 parent 01e4a6b commit 247d6c2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ install:
- 7z x SDL2-devel-2.0.8-mingw.tar
- xcopy SDL2-2.0.8\x86_64-w64-mingw32 %INSTALL_PATH% /s/e/y

- appveyor DownloadFile https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-2.0.3-mingw.tar.gz
- 7z x SDL2_image-devel-2.0.3-mingw.tar.gz
- 7z x SDL2_image-devel-2.0.3-mingw.tar
- xcopy SDL2_image-2.0.3\x86_64-w64-mingw32 %INSTALL_PATH% /s/e/y
- appveyor DownloadFile https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-2.0.1-mingw.tar.gz
- 7z x SDL2_image-devel-2.0.1-mingw.tar.gz
- 7z x SDL2_image-devel-2.0.1-mingw.tar
- xcopy SDL2_image-2.0.1\x86_64-w64-mingw32 %INSTALL_PATH% /s/e/y

- appveyor DownloadFile https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.14-mingw.tar.gz
- 7z x SDL2_ttf-devel-2.0.14-mingw.tar.gz
Expand Down
42 changes: 27 additions & 15 deletions test/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@ int main(int argc, char** argv) {
for (int i = 0; i < int(terminal.cols()); ++i)
for (int j = 0; j < int(terminal.rows()); ++j) {
terminal.setChar(i, j, 'a' + (i + j + iters) % ('z' - 'a'));
terminal.setBgColor(rterm::Color(std::min(i * 180 / terminal.cols() + iters * 127 / 1000, (size_t)0xffull),
0,
std::min(j * 180 / terminal.cols() + iters * 127 / 1000, (size_t)0xffull)), i, j);
terminal.setFgColor(rterm::Color(0xff - std::min(i * 180 / terminal.cols() + iters * 127 / 1000, (size_t)0xffull),
0xff,
0xff - std::min(j * 180 / terminal.cols() + iters * 127 / 1000, (size_t)0xffull)), i, j);
terminal.setBgColor(
rterm::Color(
std::min<unsigned>(i * 180 / terminal.cols() + iters * 127 / 1000, 0xff),
0,
std::min<unsigned>(j * 180 / terminal.cols() + iters * 127 / 1000, 0xff)
), i, j
);
terminal.setFgColor(
rterm::Color(
0xff - std::min<unsigned>(i * 180 / terminal.cols() + iters * 127 / 1000, 0xff),
0xff,
0xff - std::min<unsigned>(j * 180 / terminal.cols() + iters * 127 / 1000, 0xff)
), i, j
);
}
terminal.print(0, terminal.rows() - 1, "FPS = %d ", int(terminal.fps()));
terminal.poll();
Expand All @@ -55,15 +63,19 @@ int main(int argc, char** argv) {
start = end;

for (int iters = 0; iters < randomiters; ++iters) {
int i = rand() % terminal.cols(),
j = rand() % terminal.rows();
int i = rand() % terminal.cols();
int j = rand() % terminal.rows();
terminal.setChar(i, j, 'a' + rand() % ('z' - 'a'));
rterm::Color bg(std::min(i * 0xff / terminal.cols(), (size_t)0xffull),
0,
std::min(j * 0xff / terminal.cols(), (size_t)0xffull));
rterm::Color fg(0xff - std::min(i * 0xff / terminal.cols(), (size_t)0xffull),
0xff,
0xff - std::min(j * 0xff / terminal.cols(), (size_t)0xffull));
rterm::Color bg(
std::min<int>(i * 0xff / terminal.cols(), 0xff),
0,
std::min<int>(j * 0xff / terminal.cols(), 0xff)
);
rterm::Color fg(
0xff - std::min<int>(i * 0xff / terminal.cols(), 0xff),
0xff,
0xff - std::min<int>(j * 0xff / terminal.cols(), 0xff)
);
terminal.setBgColor(bg, i, j);
terminal.setFgColor(fg, i, j);
terminal.print(0, terminal.rows() - 1, "FPS = %d ", int(terminal.fps()));
Expand All @@ -77,7 +89,7 @@ int main(int argc, char** argv) {
deltaTime = end - start;
rterm::Logger().printf("Random time usage: %f s", deltaTime.count());
} catch (const rterm::Exception& e) {
rterm::Logger(rterm::Logger::CRITICAL) << "Cought an exception: " << e.what();
rterm::Logger(rterm::Logger::CRITICAL) << "Caught an exception: " << e.what();
}
return 0;
}

0 comments on commit 247d6c2

Please sign in to comment.