summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2013-08-15 23:27:57 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2013-09-25 02:03:17 -0300
commit6a245eba5131c2b6fcfb340c39598de1e06da892 (patch)
treeec11bcc976b3c682c0dcdb1b1dd97520ca8aa5b2
parent623478dba53b879a084ff46509963ab0b06c5c36 (diff)
downloadkmod-6a245eba5131c2b6fcfb340c39598de1e06da892.tar.gz
benchmark lookup
-rw-r--r--libkmod/libkmod-hash.c25
-rwxr-xr-xscripts/run-lookup.sh18
2 files changed, 33 insertions, 10 deletions
diff --git a/libkmod/libkmod-hash.c b/libkmod/libkmod-hash.c
index a299f06..5610861 100644
--- a/libkmod/libkmod-hash.c
+++ b/libkmod/libkmod-hash.c
@@ -285,15 +285,7 @@ static inline unsigned int hash_paul(const char *key, unsigned int len)
static _always_inline_ unsigned int hashfunc(const char *key, unsigned int len)
{
- unsigned long t;
- unsigned int ret;
- t = get_cycles(0);
- ret = MurmurHash3_x86_32(key, len);
- t = get_cycles(t);
-
- printf("%u %lu\n", len, t);
-
- return ret;
+ return hash_crc32c_hw(key, len);
}
/*
@@ -424,7 +416,7 @@ static int hash_entry_cmp(const void *pa, const void *pb)
return strcmp(a->key, b->key);
}
-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);
@@ -442,6 +434,19 @@ void *hash_find(const struct hash *hash, const char *key)
return (void *)entry->value;
}
+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);
diff --git a/scripts/run-lookup.sh b/scripts/run-lookup.sh
new file mode 100755
index 0000000..4038b55
--- /dev/null
+++ b/scripts/run-lookup.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+log="$1"
+
+for ((i=0; i < 10;))
+do
+ err=${log}.${i}.stderr
+ echo "running #$i"
+ sudo chrt -f 99 /usr/bin/time -f \
+ "\n***\ntime: %E\ncontext switches: %c\nwaits: %w" \
+ tools/depmod -a > ${log}.$i 2>$err
+ [[ ! -z "$(grep 'context switches: 0' $err)" ]] && ((i++))
+done
+
+echo "consolidating in $log"
+rm ${log}.0*
+cat "$log".[1-9] | scripts/parse-timing > $log
+rm ${log}.*