benchmark add
This commit is contained in:
parent
6a245eba51
commit
b90ef3a1b8
|
@ -294,7 +294,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!
|
||||
*/
|
||||
int hash_add(struct hash *hash, const char *key, const void *value)
|
||||
static _always_inline_ int _hash_add(struct hash *hash, const char *key, const void *value)
|
||||
{
|
||||
unsigned int keylen = strlen(key);
|
||||
unsigned int hashval = hashfunc(key, keylen);
|
||||
|
@ -334,6 +334,20 @@ int hash_add(struct hash *hash, const char *key, const void *value)
|
|||
hash->count++;
|
||||
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)
|
||||
{
|
||||
|
@ -371,7 +385,7 @@ void hash_dump_keys(struct hash *hash) {}
|
|||
#endif
|
||||
|
||||
/* similar to hash_add(), but fails if key already exists */
|
||||
int hash_add_unique(struct hash *hash, const char *key, const void *value)
|
||||
static _always_inline_ int _hash_add_unique(struct hash *hash, const char *key, const void *value)
|
||||
{
|
||||
unsigned int keylen = strlen(key);
|
||||
unsigned int hashval = hashfunc(key, keylen);
|
||||
|
@ -409,6 +423,19 @@ int hash_add_unique(struct hash *hash, const char *key, const void *value)
|
|||
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;
|
||||
}
|
||||
|
||||
static int hash_entry_cmp(const void *pa, const void *pb)
|
||||
{
|
||||
const struct hash_entry *a = pa;
|
||||
|
@ -416,7 +443,7 @@ static int hash_entry_cmp(const void *pa, const void *pb)
|
|||
return strcmp(a->key, b->key);
|
||||
}
|
||||
|
||||
static _always_inline_ void *_hash_find(const struct hash *hash, const char *key)
|
||||
void *hash_find(const struct hash *hash, const char *key)
|
||||
{
|
||||
unsigned int keylen = strlen(key);
|
||||
unsigned int hashval = hashfunc(key, keylen);
|
||||
|
@ -434,19 +461,6 @@ static _always_inline_ 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);
|
||||
|
|
|
@ -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".* | scripts/parse-timing > $log
|
||||
rm ${log}.*
|
Loading…
Reference in New Issue