Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 247d6c2

Browse files
committedAug 13, 2018
Fix benchmarks in appveyor
1 parent 01e4a6b commit 247d6c2

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed
 

‎.appveyor.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ install:
2424
- 7z x SDL2-devel-2.0.8-mingw.tar
2525
- xcopy SDL2-2.0.8\x86_64-w64-mingw32 %INSTALL_PATH% /s/e/y
2626

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

3232
- appveyor DownloadFile https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.14-mingw.tar.gz
3333
- 7z x SDL2_ttf-devel-2.0.14-mingw.tar.gz

‎test/benchmark.cpp

+27-15
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@ int main(int argc, char** argv) {
3232
for (int i = 0; i < int(terminal.cols()); ++i)
3333
for (int j = 0; j < int(terminal.rows()); ++j) {
3434
terminal.setChar(i, j, 'a' + (i + j + iters) % ('z' - 'a'));
35-
terminal.setBgColor(rterm::Color(std::min(i * 180 / terminal.cols() + iters * 127 / 1000, (size_t)0xffull),
36-
0,
37-
std::min(j * 180 / terminal.cols() + iters * 127 / 1000, (size_t)0xffull)), i, j);
38-
terminal.setFgColor(rterm::Color(0xff - std::min(i * 180 / terminal.cols() + iters * 127 / 1000, (size_t)0xffull),
39-
0xff,
40-
0xff - std::min(j * 180 / terminal.cols() + iters * 127 / 1000, (size_t)0xffull)), i, j);
35+
terminal.setBgColor(
36+
rterm::Color(
37+
std::min<unsigned>(i * 180 / terminal.cols() + iters * 127 / 1000, 0xff),
38+
0,
39+
std::min<unsigned>(j * 180 / terminal.cols() + iters * 127 / 1000, 0xff)
40+
), i, j
41+
);
42+
terminal.setFgColor(
43+
rterm::Color(
44+
0xff - std::min<unsigned>(i * 180 / terminal.cols() + iters * 127 / 1000, 0xff),
45+
0xff,
46+
0xff - std::min<unsigned>(j * 180 / terminal.cols() + iters * 127 / 1000, 0xff)
47+
), i, j
48+
);
4149
}
4250
terminal.print(0, terminal.rows() - 1, "FPS = %d ", int(terminal.fps()));
4351
terminal.poll();
@@ -55,15 +63,19 @@ int main(int argc, char** argv) {
5563
start = end;
5664

5765
for (int iters = 0; iters < randomiters; ++iters) {
58-
int i = rand() % terminal.cols(),
59-
j = rand() % terminal.rows();
66+
int i = rand() % terminal.cols();
67+
int j = rand() % terminal.rows();
6068
terminal.setChar(i, j, 'a' + rand() % ('z' - 'a'));
61-
rterm::Color bg(std::min(i * 0xff / terminal.cols(), (size_t)0xffull),
62-
0,
63-
std::min(j * 0xff / terminal.cols(), (size_t)0xffull));
64-
rterm::Color fg(0xff - std::min(i * 0xff / terminal.cols(), (size_t)0xffull),
65-
0xff,
66-
0xff - std::min(j * 0xff / terminal.cols(), (size_t)0xffull));
69+
rterm::Color bg(
70+
std::min<int>(i * 0xff / terminal.cols(), 0xff),
71+
0,
72+
std::min<int>(j * 0xff / terminal.cols(), 0xff)
73+
);
74+
rterm::Color fg(
75+
0xff - std::min<int>(i * 0xff / terminal.cols(), 0xff),
76+
0xff,
77+
0xff - std::min<int>(j * 0xff / terminal.cols(), 0xff)
78+
);
6779
terminal.setBgColor(bg, i, j);
6880
terminal.setFgColor(fg, i, j);
6981
terminal.print(0, terminal.rows() - 1, "FPS = %d ", int(terminal.fps()));
@@ -77,7 +89,7 @@ int main(int argc, char** argv) {
7789
deltaTime = end - start;
7890
rterm::Logger().printf("Random time usage: %f s", deltaTime.count());
7991
} catch (const rterm::Exception& e) {
80-
rterm::Logger(rterm::Logger::CRITICAL) << "Cought an exception: " << e.what();
92+
rterm::Logger(rterm::Logger::CRITICAL) << "Caught an exception: " << e.what();
8193
}
8294
return 0;
8395
}

0 commit comments

Comments
 (0)
Please sign in to comment.