summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2013-09-25 02:07:47 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2013-09-25 02:07:47 -0300
commitd7ac0805bd21fe293b85ea23ba714e617ac2b701 (patch)
tree043c2038470d0b7dd24f30b8ed3c650a45daf45c
parentf758b1f92ad3c8f2699344f2b47566b26d6e7497 (diff)
downloadkmod-hash-stat2.tar.gz
benchmark hashfindhash-stat2
-rw-r--r--libkmod/libkmod-hash.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/libkmod/libkmod-hash.c b/libkmod/libkmod-hash.c
index 5bf2077..7d5eee7 100644
--- a/libkmod/libkmod-hash.c
+++ b/libkmod/libkmod-hash.c
@@ -295,7 +295,7 @@ static _always_inline_ unsigned int hashfunc(const char *key, unsigned int len)
* none of key or value are copied, just references are remembered as is,
* make sure they are live while pair exists in hash!
*/
-static _always_inline_ int _hash_add(struct hash *hash, const char *key, const void *value)
+int hash_add(struct hash *hash, const char *key, const void *value)
{
unsigned int keylen = strlen(key);
unsigned int hashval = hashfunc(key, keylen);
@@ -332,19 +332,6 @@ static _always_inline_ int _hash_add(struct hash *hash, const char *key, const v
return 0;
}
-int hash_add(struct hash *hash, const char *key, const void *value)
-{
- unsigned long t;
- int ret;
-
- t = get_cycles(0);
- ret = _hash_add(hash, key, value);
- t = get_cycles(t);
-
- printf("%lu %lu\n", strlen(key), t);
- return ret;
-}
-
#if 0
void hash_dump(struct hash *hash)
{
@@ -382,7 +369,7 @@ void hash_dump_keys(struct hash *hash) {}
#endif
/* similar to hash_add(), but fails if key already exists */
-static _always_inline_ int _hash_add_unique(struct hash *hash, const char *key, const void *value)
+int hash_add_unique(struct hash *hash, const char *key, const void *value)
{
unsigned int keylen = strlen(key);
unsigned int hashval = hashfunc(key, keylen);
@@ -415,20 +402,7 @@ static _always_inline_ int _hash_add_unique(struct hash *hash, const char *key,
return 0;
}
-int hash_add_unique(struct hash *hash, const char *key, const void *value)
-{
- unsigned long t;
- int ret;
-
- t = get_cycles(0);
- ret = _hash_add_unique(hash, key, value);
- t = get_cycles(t);
-
- printf("%lu %lu\n", strlen(key), t);
- return ret;
-}
-
-void *hash_find(const struct hash *hash, const char *key)
+static _always_inline_ void *_hash_find(const struct hash *hash, const char *key)
{
unsigned int keylen = strlen(key);
unsigned int hashval = hashfunc(key, keylen);
@@ -446,6 +420,19 @@ void *hash_find(const struct hash *hash, const char *key)
return NULL;
}
+void *hash_find(const struct hash *hash, const char *key)
+{
+ unsigned long t;
+ void *ret;
+
+ t = get_cycles(0);
+ ret = _hash_find(hash, key);
+ t = get_cycles(t);
+
+ printf("%lu %lu\n", strlen(key), t);
+ return ret;
+}
+
int hash_del(struct hash *hash, const char *key)
{
unsigned int keylen = strlen(key);