diff options
author | hunt <hunt> | 2005-11-11 06:13:24 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-11-11 06:13:24 +0000 |
commit | 15997cc74dd4e2a17b62d49d45eee410cd0db49c (patch) | |
tree | 1b241f8f0137842d1242207efbf0b80e7368f0d2 /runtime/tests/pmaps/ix2.c | |
parent | 6ed93e502ec2845f4e1f76cd33e917d613c66863 (diff) | |
download | systemtap-steved-15997cc74dd4e2a17b62d49d45eee410cd0db49c.tar.gz systemtap-steved-15997cc74dd4e2a17b62d49d45eee410cd0db49c.tar.xz systemtap-steved-15997cc74dd4e2a17b62d49d45eee410cd0db49c.zip |
2005-11-10 Martin Hunt <hunt@redhat.com>
* pmaps/ix2.c: New test. Test _stp_pmap_get_*().
* pmaps/iii3.c: New test. Test _stp_pmap_get_*().
* pmaps/pmap.test: Update.
Diffstat (limited to 'runtime/tests/pmaps/ix2.c')
-rw-r--r-- | runtime/tests/pmaps/ix2.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/runtime/tests/pmaps/ix2.c b/runtime/tests/pmaps/ix2.c new file mode 100644 index 00000000..6016bf53 --- /dev/null +++ b/runtime/tests/pmaps/ix2.c @@ -0,0 +1,64 @@ +#include "runtime.h" + +/* test of pmaps with keys of int64 and value of stat */ + +#define VALUE_TYPE STAT +#define KEY1_TYPE INT64 +#include "pmap-gen.c" + +#include "map.c" + +int main () +{ + MAP map = _stp_pmap_new_ix(4, HIST_LINEAR, 0, 100, 10); + int i; + + /* put some data in. _processor_number is a global hack that allows */ + /* us to set the current emulated cpu number for our userspace tests. */ + /* Note that we set values based on the cpu number just to show that */ + /* different values are stored in each cpu */ + for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { + _stp_pmap_add_ix(map, 1, _processor_number); + _stp_pmap_add_ix(map, 2, 10 *_processor_number + 1); + _stp_pmap_add_ix(map, 3, _processor_number * _processor_number); + _stp_pmap_add_ix(map, 4, 1); + } + + /* now print the per-cpu data */ + for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { + printf("CPU #%d\n", _processor_number); + _stp_pmap_printn_cpu (map, + 0, + "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M", + _processor_number); + } + _processor_number = 0; + + /* print the aggregated data */ + _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); + + /* now use GET */ + for (i = 1; i < 5; i++) + printf("map[%d] Sum = %lld\n", i, _stp_pmap_get_ix(map, i)->sum); + printf("\n"); + + /* delete an entry and repeat */ + for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) + _stp_pmap_set_ix(map, 2, 0); + _processor_number = 0; + + /* print the aggregated data */ + _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); + + /* now use GET */ + for (i = 1; i < 5; i++) { + stat *sd = _stp_pmap_get_ix(map, i); + if (sd) + printf("map[%d] Sum = %lld\n", i, sd->sum); + } + printf("\n"); + + _stp_pmap_del (map); + return 0; +} + |