From 728cbe102108be8296f2485e384392a4408ce9db Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Sat, 20 Feb 2016 13:06:08 -0800 Subject: [PATCH] force profiler_unittest to do 'real' work 'XOR loop' in profiler unittest wasn't 100% effective because it allowed compiler to avoid loading and storing to memory. After marking result variable as volatile, we're now forcing compiler to read and write memory, slowing this loops down sufficiently. And profiler_unittest is now passing more consistently. Closes #628 --- src/tests/profiler_unittest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/profiler_unittest.cc b/src/tests/profiler_unittest.cc index 321f848..dfc653f 100644 --- a/src/tests/profiler_unittest.cc +++ b/src/tests/profiler_unittest.cc @@ -46,7 +46,7 @@ #include "base/simple_mutex.h" #include "tests/testutil.h" -static int result = 0; +static volatile int result = 0; static int g_iters = 0; // argv[1] Mutex mutex(Mutex::LINKER_INITIALIZED);