Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: unit_test/color_test.cc

Issue 1367403007: Speed up rounding to byte test (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/libyuv/version.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unit_test/color_test.cc
diff --git a/unit_test/color_test.cc b/unit_test/color_test.cc
index d3fda0d4dcd7faa0b82b74c70997fad0f59f9dff..81189083dc18690d0afb5555301e4e02b9889386 100644
--- a/unit_test/color_test.cc
+++ b/unit_test/color_test.cc
@@ -229,10 +229,10 @@ static void YJToRGB(int y, int* r, int* g, int* b) {
// #define CLAMPMETHOD_MASK 1
// Pick a method for rounding.
-#define ROUND(f) static_cast<int>(f + 0.5)
-// #define ROUND(f) lrintf(f)
-// #define ROUND(f) static_cast<int>(round(f))
-// #define ROUND(f) _mm_cvt_ss2si(_mm_load_ss(&f))
+#define ROUND(f) lrintf(f)
brucedawson 2015/10/02 18:48:07 But, lrintf is ~376 times slower on VC++ (https://
fbarchard 2015/10/02 21:44:53 Done.
+//#define ROUND(f) static_cast<int>(f + 0.5)
+//#define ROUND(f) static_cast<int>(round(f))
+//#define ROUND(f) _mm_cvt_ss2si(_mm_load_ss(&f))
#if defined(CLAMPMETHOD_IF)
static int RoundToByte(float f) {
@@ -314,16 +314,11 @@ static int RoundToByte(float f) {
TEST_F(libyuvTest, TestRoundToByte) {
int allb = 0;
- for (int i = 0; i < benchmark_iterations_; ++i) {
- for (int u2 = 0; u2 < 256; ++u2) {
- for (int v2 = 0; v2 < 256; ++v2) {
- for (int y2 = 0; y2 < 256; ++y2) {
- int y = RANDOM256(y2);
- int b = RoundToByte(y * 810.33 - 257);
- allb |= b;
- }
- }
- }
+ int count = benchmark_width_ * benchmark_height_ * benchmark_iterations_;
+ for (int i = 0; i < count; ++i) {
+ int y = RANDOM256(i);
+ int b = RoundToByte(y * 810.33 - 257);
+ allb |= b;
}
EXPECT_GE(allb, 0);
EXPECT_LE(allb, 255);
« no previous file with comments | « include/libyuv/version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698