]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
benchmark hashfind hash-stat2
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 25 Sep 2013 05:07:47 +0000 (02:07 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 25 Sep 2013 05:07:47 +0000 (02:07 -0300)
libkmod/libkmod-hash.c

index 5bf2077878101b8bdb9125c0e561ff006d6befe1..7d5eee7133c9852167394b5bbac628e593679279 100644 (file)
@@ -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);