summaryrefslogtreecommitdiffstats
path: root/bench/libdimension/array.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-10-23 18:45:56 +0000
committerTavian Barnes <tavianator@gmail.com>2009-10-23 18:45:56 +0000
commit1742345f241268e493dcbfe4b54e62c77ccbfadc (patch)
tree1ca4037a6120e461eb28764b2c7942735b5cf04b /bench/libdimension/array.c
parentd7c2ee8dbdf9f79588b2d6b2f2d34861638ae231 (diff)
downloaddimension-1742345f241268e493dcbfe4b54e62c77ccbfadc.tar.xz
Upgrade benchmarks to latest libsandglass.
Diffstat (limited to 'bench/libdimension/array.c')
-rw-r--r--bench/libdimension/array.c85
1 files changed, 14 insertions, 71 deletions
diff --git a/bench/libdimension/array.c b/bench/libdimension/array.c
index 692fae3..1909b85 100644
--- a/bench/libdimension/array.c
+++ b/bench/libdimension/array.c
@@ -33,7 +33,7 @@ main()
const unsigned int count = 32;
sandglass_t sandglass;
- sandglass_attributes_t attr = { SANDGLASS_MONOTONIC, SANDGLASS_REALTICKS };
+ sandglass_attributes_t attr = { SANDGLASS_MONOTONIC, SANDGLASS_CPUTIME };
if (sandglass_create(&sandglass, &attr, &attr) != 0) {
perror("sandglass_create()");
@@ -41,7 +41,7 @@ main()
}
/* Benchmark allocation and deallocation */
- sandglass_bench(&sandglass, {
+ sandglass_bench_fine(&sandglass, {
array = dmnsn_new_array(sizeof(object));
dmnsn_delete_array(array);
});
@@ -54,79 +54,43 @@ main()
printf("dmnsn_array_push():");
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
-
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
- sandglass.baseline = sandglass.grains;
-
for (i = 0; i < count; ++i) {
- sandglass_begin(&sandglass);
- dmnsn_array_push(array, &object);
- sandglass_elapse(&sandglass);
- sandglass.grains -= sandglass.baseline;
-
+ sandglass_bench_noprecache(&sandglass, dmnsn_array_push(array, &object));
printf(" %ld", sandglass.grains);
}
printf("\n");
/* dmnsn_array_get() */
- sandglass_bench(&sandglass, dmnsn_array_get(array, count/2, &object));
+ sandglass_bench_fine(&sandglass, dmnsn_array_get(array, count/2, &object));
printf("dmnsn_array_get(): %ld\n", sandglass.grains);
/* dmnsn_array_set() */
- sandglass_bench(&sandglass, dmnsn_array_set(array, count/2, &object));
+ sandglass_bench_fine(&sandglass, dmnsn_array_set(array, count/2, &object));
printf("dmnsn_array_set(): %ld\n", sandglass.grains);
/* dmnsn_array_at() */
- sandglass_bench(&sandglass, ptr = dmnsn_array_at(array, count/2));
+ sandglass_bench_fine(&sandglass, ptr = dmnsn_array_at(array, count/2));
printf("dmnsn_array_at(): %ld\n", sandglass.grains);
/* dmnsn_array_size() */
- sandglass_bench(&sandglass, size = dmnsn_array_size(array));
+ sandglass_bench_fine(&sandglass, size = dmnsn_array_size(array));
printf("dmnsn_array_size(): %ld\n", sandglass.grains);
/* dmnsn_array_resize() */
-
dmnsn_array_resize(array, count);
-
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
-
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
- sandglass.baseline = sandglass.grains;
-
- sandglass_begin(&sandglass);
- dmnsn_array_resize(array, count * 2);
- sandglass_elapse(&sandglass);
- sandglass.grains -= sandglass.baseline;
+ sandglass_bench_noprecache(&sandglass, dmnsn_array_resize(array, count * 2));
printf("dmnsn_array_resize(): %ld", sandglass.grains);
- sandglass_begin(&sandglass);
- dmnsn_array_resize(array, count);
- sandglass_elapse(&sandglass);
- sandglass.grains -= sandglass.baseline;
+ sandglass_bench_noprecache(&sandglass, dmnsn_array_resize(array, count));
printf(" %ld\n", sandglass.grains);
/* dmnsn_array_insert() */
printf("dmnsn_array_insert():");
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
-
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
- sandglass.baseline = sandglass.grains;
-
for (i = 0; i < count; ++i) {
- sandglass_begin(&sandglass);
- dmnsn_array_insert(array, count/2, &object);
- sandglass_elapse(&sandglass);
- sandglass.grains -= sandglass.baseline;
-
+ sandglass_bench_noprecache(&sandglass,
+ dmnsn_array_insert(array, count/2, &object));
printf(" %ld", sandglass.grains);
}
printf("\n");
@@ -135,19 +99,9 @@ main()
printf("dmnsn_array_remove():");
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
-
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
- sandglass.baseline = sandglass.grains;
-
for (i = 0; i < count; ++i) {
- sandglass_begin(&sandglass);
- dmnsn_array_remove(array, count/2);
- sandglass_elapse(&sandglass);
- sandglass.grains -= sandglass.baseline;
-
+ sandglass_bench_noprecache(&sandglass,
+ dmnsn_array_remove(array, count/2));
printf(" %ld", sandglass.grains);
}
printf("\n");
@@ -156,19 +110,8 @@ main()
printf("dmnsn_array_pop():");
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
-
- sandglass_begin(&sandglass);
- sandglass_elapse(&sandglass);
- sandglass.baseline = sandglass.grains;
-
for (i = 0; i < count; ++i) {
- sandglass_begin(&sandglass);
- dmnsn_array_pop(array, &object);
- sandglass_elapse(&sandglass);
- sandglass.grains -= sandglass.baseline;
-
+ sandglass_bench_noprecache(&sandglass, dmnsn_array_pop(array, &object));
printf(" %ld", sandglass.grains);
}
printf("\n");