Fix representative issue in bench which result in too much computation
being removed by the compiler.
This commit is contained in:
1 parent
c32f6a9e5b
commit
c5299589bb
5 files changed
+39
-2
No files matched your search
+9
-1
@@ -17,6 +17,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
@@ -61,6 +63,7 @@ static void test_list(size_t n)
|
||||
for (list<unsigned int>::const_iterator ci1 = a1.begin(), ci2 = a2.begin (); ci1 != a1.end(); ++ci1, ++ci2) {
|
||||
s += *ci1 * *ci2;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -77,6 +80,7 @@ static void test_array(size_t n)
|
||||
for(unsigned long i = 0; i < n; i++) {
|
||||
s += a1[i] * a2[i];
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -96,6 +100,7 @@ static void test_rbtree(size_t n)
|
||||
if (it != tree.end())
|
||||
s += *it;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -116,6 +121,7 @@ test_dict1(unsigned long n)
|
||||
if (it != dict.end())
|
||||
s += it->second;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -136,6 +142,7 @@ test_dict2(unsigned long n)
|
||||
if (it != dict.end())
|
||||
s += it->second;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -178,7 +185,8 @@ test_dict_big(unsigned long n)
|
||||
unordered_map<char_array_s, char_array_s>::iterator it = dict.find(s1);
|
||||
if (it != dict.end())
|
||||
s ++;
|
||||
}
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
Reference in new issue
Block a user