-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da20a08
commit 1982366
Showing
10 changed files
with
102 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
#ifndef BENCHMARKS_MAP_H_INCLUDED | ||
#define BENCHMARKS_MAP_H_INCLUDED | ||
|
||
typedef struct map_metric map_metric; | ||
struct map_metric | ||
{ | ||
char *name; | ||
void (*measure)(map_metric *, uint32_t *, size_t); | ||
double insert; | ||
double at; | ||
double erase; | ||
}; | ||
|
||
uint64_t ntime(void); | ||
|
||
#endif /* BENCHMARKS_MAP_H_INCLUDED */ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <stdint.h> | ||
#include <sys/param.h> | ||
#include <err.h> | ||
#include <time.h> | ||
|
||
#include "dynamic.h" | ||
#include "map.h" | ||
|
||
typedef struct map_element map_element; | ||
struct map_element | ||
{ | ||
uint32_t key; | ||
uint32_t value; | ||
}; | ||
|
||
static size_t hash(void *e) | ||
{ | ||
return *(uint32_t *) e; | ||
} | ||
|
||
static int equal(void *e1, void *e2) | ||
{ | ||
return *(uint32_t *) e1 == *(uint32_t *) e2; | ||
} | ||
|
||
static void set(void *e1, void *e2) | ||
{ | ||
*(uint64_t *) e1 = *(uint64_t *) e2; | ||
} | ||
|
||
void map_libdynamic(int *keys, int *keys_shuffled, int *values, size_t size, size_t lookups, double *insert, double *lookup, double *erase, uint64_t *sum) | ||
{ | ||
map m; | ||
uint64_t t1, t2, s; | ||
size_t i, n; | ||
|
||
map_construct(&m, sizeof(map_element), (map_element[]) {{.key = -1}}, set); | ||
|
||
t1 = ntime(); | ||
for (i = 0; i < size; i ++) | ||
map_insert(&m, (map_element[]) {{.key = keys[i], .value = values[i]}}, hash, equal, set, NULL); | ||
t2 = ntime(); | ||
*insert = (double) (t2 - t1) / size; | ||
|
||
s = 0; | ||
t1 = ntime(); | ||
for (n = lookups; n; n -= i) | ||
for (i = 0; i < MIN(size, n); i ++) | ||
s += ((map_element *) map_at(&m, (map_element[]){{.key = keys_shuffled[i]}}, hash, equal))->value; | ||
t2 = ntime(); | ||
*sum = s; | ||
*lookup = (double) (t2 - t1) / lookups; | ||
|
||
t1 = ntime(); | ||
for (i = 0; i < size; i ++) | ||
map_erase(&m, (map_element[]){{.key = keys[i]}}, hash, equal, set, NULL); | ||
t2 = ntime(); | ||
if (map_size(&m)) | ||
errx(1, "inconsistency"); | ||
*erase = (double) (t2 - t1) / size; | ||
|
||
map_destruct(&m, NULL, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef MAP_LIBDYNAMIC_H_INCLUDED | ||
#define MAP_LIBDYNAMIC_H_INCLUDED | ||
|
||
void map_libdynamic(int *, int *, int *, size_t, size_t, double *, double *, double *, uint64_t *); | ||
|
||
#endif /* MAP_LIBDYNAMIC_H_INCLUDED */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef MAP_LIBDYNAMIC_SUBCLASS_H_INCLUDED | ||
#define MAP_LIBDYNAMIC_SUBCLASS_H_INCLUDED | ||
|
||
void map_libdynamic_subclass(int *, int *, int *, size_t, size_t, double *, double *, double *, uint64_t *); | ||
|
||
#endif /* MAP_LIBDYNAMIC_SUBCLASS_H_INCLUDED */ |
This file was deleted.
Oops, something went wrong.