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
@@ -10,6 +10,8 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
@@ -58,6 +60,7 @@ static void test_array(size_t n)
|
||||
for(unsigned long i = 0; i < n; i++) {
|
||||
s += g_array_index(a1, unsigned int, i ) * g_array_index(a2, unsigned int, i );
|
||||
}
|
||||
g_result = s;
|
||||
g_array_free(a1, FALSE);
|
||||
g_array_free(a2, FALSE);
|
||||
}
|
||||
@@ -78,6 +81,7 @@ static void test_list (size_t n)
|
||||
s += GPOINTER_TO_INT(it1->data) * GPOINTER_TO_INT(it2->data);
|
||||
n--;
|
||||
}
|
||||
g_result = s;
|
||||
g_slist_free(a1);
|
||||
g_slist_free(a2);
|
||||
}
|
||||
@@ -109,6 +113,7 @@ static void test_rbtree(size_t n)
|
||||
if (p)
|
||||
s += *p;
|
||||
}
|
||||
g_result = s;
|
||||
g_tree_destroy(tree);
|
||||
}
|
||||
|
||||
@@ -145,6 +150,7 @@ test_dict(unsigned long n)
|
||||
if (p)
|
||||
s += *p;
|
||||
}
|
||||
g_result = s;
|
||||
g_hash_table_destroy(dict);
|
||||
}
|
||||
|
||||
@@ -188,6 +194,7 @@ test_dict_big(unsigned long n)
|
||||
if (p)
|
||||
s ++;
|
||||
}
|
||||
g_result = s;
|
||||
g_hash_table_destroy(dict);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "kbtree.h"
|
||||
#include "khash.h"
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
@@ -60,6 +62,7 @@ static void test_array(size_t n)
|
||||
for(unsigned long i = 0; i < n; i++) {
|
||||
s += kv_A(a1, i ) * kv_A(a2, i );
|
||||
}
|
||||
g_result = s;
|
||||
|
||||
kv_destroy(a1);
|
||||
kv_destroy(a2);
|
||||
@@ -88,6 +91,7 @@ static void test_list (size_t n)
|
||||
it1 = kl_next(it1), it2 = kl_next(it2)) {
|
||||
s += kl_val(it1) * kl_val(it2);
|
||||
}
|
||||
g_result = s;
|
||||
|
||||
kl_destroy(32, a1);
|
||||
kl_destroy(32, a2);
|
||||
@@ -116,6 +120,7 @@ static void test_rbtree(size_t n)
|
||||
if (kb_getp(kTree, tree, &j) != 0)
|
||||
s+= j;
|
||||
}
|
||||
g_result = s;
|
||||
kb_destroy(kTree, tree);
|
||||
}
|
||||
|
||||
@@ -143,6 +148,7 @@ test_dict(unsigned long n)
|
||||
if (kh_exist(dict, k))
|
||||
s += kh_value(dict, k);
|
||||
}
|
||||
g_result = s;
|
||||
|
||||
kh_destroy(iun, dict);
|
||||
}
|
||||
@@ -186,6 +192,7 @@ test_dict_big(unsigned long n)
|
||||
if (kh_exist(dict, k))
|
||||
s ++;
|
||||
}
|
||||
g_result = s;
|
||||
|
||||
kh_destroy(iub, dict);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "m-rbtree.h"
|
||||
#include "m-dict.h"
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
@@ -58,6 +60,7 @@ static void test_array(size_t n)
|
||||
for(unsigned long i = 0; i < n; i++) {
|
||||
s += *array_uint_cget(a1, i ) * *array_uint_cget(a2, i );
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +81,7 @@ static void test_list (size_t n)
|
||||
for(list_uint_it(it1, a1), list_uint_it(it2,a2); !list_uint_end_p(it1); list_uint_next(it1), list_uint_next(it2)) {
|
||||
s += *list_uint_cref(it1) * *list_uint_cref(it2);
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +103,7 @@ static void test_rbtree(size_t n)
|
||||
if (p)
|
||||
s += *p;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +126,7 @@ test_dict(unsigned long n)
|
||||
if (p)
|
||||
s += *p;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +167,7 @@ test_dict_big(unsigned long n)
|
||||
if (p)
|
||||
s ++;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
@@ -60,6 +62,7 @@ static void test_list(size_t n)
|
||||
for (QLinkedList<unsigned int>::const_iterator ci1 = a1.begin(), ci2 = a2.begin (); ci1 != a1.end(); ++ci1, ++ci2) {
|
||||
s += *ci1 * *ci2;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -76,6 +79,7 @@ static void test_array(size_t n)
|
||||
for(unsigned long i = 0; i < n; i++) {
|
||||
s += a1[i] * a2[i];
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -98,6 +102,7 @@ static void test_rbtree(size_t n)
|
||||
if (it != tree.end())
|
||||
s += *it;
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -119,6 +124,7 @@ test_dict1(unsigned long n)
|
||||
if (it != dict.end())
|
||||
s += it.value();
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -139,6 +145,7 @@ test_dict2(unsigned long n)
|
||||
if (it != dict.end())
|
||||
s += it.value();
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
@@ -177,7 +184,8 @@ test_dict_big(unsigned long n)
|
||||
QHash<char_array_s, char_array_s>::iterator it = dict.find(s1);
|
||||
if (it != dict.end())
|
||||
s ++;
|
||||
}
|
||||
}
|
||||
g_result = s;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
+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