-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a2f286
commit 5c50d9f
Showing
4 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/**************************************************************************** | ||
** MIT License | ||
** | ||
** Author : xiaofeng.zhu | ||
** Support : [email protected], [email protected] | ||
** | ||
****************************************************************************/ | ||
#include <gtest/gtest.h> | ||
#include "benchmark.h" | ||
|
||
#if defined(_MSC_VER) && (_MSC_VER >= 1500 && _MSC_VER < 1900) | ||
/* msvc兼容utf-8: https://support.microsoft.com/en-us/kb/980263 */ | ||
#if (_MSC_VER >= 1700) | ||
#pragma execution_character_set("utf-8") | ||
#endif | ||
#pragma warning(disable : 4566) | ||
#endif | ||
|
||
TEST(benchmark, once) | ||
{ | ||
for (int i = 0; i < Hardware::GetCPUs(); ++i) | ||
{ | ||
double use_ms = Benchmark::RunOnce(); | ||
double score = Benchmark::Score(use_ms); | ||
|
||
std::cout << "benchmark score: " << score << std::endl; | ||
if (use_ms < 100) | ||
ASSERT_GT(score, 0); | ||
else if (use_ms > 100) | ||
ASSERT_LT(score, 0); | ||
else /* 100 */ | ||
ASSERT_EQ(score, 0); | ||
} | ||
} | ||
|
||
TEST(benchmark, multi_thread) | ||
{ | ||
double score = Benchmark::RunMultiThread(3); | ||
|
||
std::cout << "benchmark multi_thread score: " << score << std::endl; | ||
ASSERT_NE(score, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.