From 247d6c25290a6cee8dfd91a85e774e0507848820 Mon Sep 17 00:00:00 2001 From: BigRedEye Date: Mon, 13 Aug 2018 18:08:26 +0300 Subject: [PATCH] Fix benchmarks in appveyor --- .appveyor.yml | 8 ++++---- test/benchmark.cpp | 42 +++++++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index a88271a..a19fb17 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -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 diff --git a/test/benchmark.cpp b/test/benchmark.cpp index 41a9ad0..bc01e08 100644 --- a/test/benchmark.cpp +++ b/test/benchmark.cpp @@ -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(i * 180 / terminal.cols() + iters * 127 / 1000, 0xff), + 0, + std::min(j * 180 / terminal.cols() + iters * 127 / 1000, 0xff) + ), i, j + ); + terminal.setFgColor( + rterm::Color( + 0xff - std::min(i * 180 / terminal.cols() + iters * 127 / 1000, 0xff), + 0xff, + 0xff - std::min(j * 180 / terminal.cols() + iters * 127 / 1000, 0xff) + ), i, j + ); } terminal.print(0, terminal.rows() - 1, "FPS = %d ", int(terminal.fps())); terminal.poll(); @@ -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(i * 0xff / terminal.cols(), 0xff), + 0, + std::min(j * 0xff / terminal.cols(), 0xff) + ); + rterm::Color fg( + 0xff - std::min(i * 0xff / terminal.cols(), 0xff), + 0xff, + 0xff - std::min(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())); @@ -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; }