diff options
author | hunt <hunt> | 2005-11-28 20:08:09 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-11-28 20:08:09 +0000 |
commit | cfedbab4fefea3f09a29c1e0f26ac3373e83e3ea (patch) | |
tree | 78155857205019a90d77278b0a061728e9dde1d8 | |
parent | b34a14ef3dc05fa843020e507d086bb35f641ca0 (diff) | |
download | systemtap-steved-cfedbab4fefea3f09a29c1e0f26ac3373e83e3ea.tar.gz systemtap-steved-cfedbab4fefea3f09a29c1e0f26ac3373e83e3ea.tar.xz systemtap-steved-cfedbab4fefea3f09a29c1e0f26ac3373e83e3ea.zip |
2005-11-28 Martin Hunt <hunt@redhat.com>
* map-stat.c (_stp_pmap_new_hstat_log): Fix typo. Call
_stp_pmap_new() instead of _stp_map_new().
-rw-r--r-- | runtime/ChangeLog | 5 | ||||
-rw-r--r-- | runtime/map-stat.c | 2 | ||||
-rw-r--r-- | runtime/tests/ChangeLog | 6 | ||||
-rw-r--r-- | runtime/tests/pmaps/ix_log.c | 62 | ||||
-rw-r--r-- | runtime/tests/pmaps/ix_none.c | 62 | ||||
-rw-r--r-- | runtime/tests/pmaps/pmap.test | 148 |
6 files changed, 284 insertions, 1 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 8df9ac99..01a28730 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2005-11-28 Martin Hunt <hunt@redhat.com> + + * map-stat.c (_stp_pmap_new_hstat_log): Fix typo. Call + _stp_pmap_new() instead of _stp_map_new(). + 2005-11-11 Martin Hunt <hunt@redhat.com> * map.h: Removed old API macros and prototypes. diff --git a/runtime/map-stat.c b/runtime/map-stat.c index 7d4e72aa..51377d00 100644 --- a/runtime/map-stat.c +++ b/runtime/map-stat.c @@ -101,7 +101,7 @@ static MAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size, int buck { /* add size for buckets */ int size = buckets * sizeof(int64_t) + sizeof(stat); - MAP map = _stp_map_new (max_entries, STAT, key_size, size); + MAP map = _stp_pmap_new (max_entries, STAT, key_size, size); if (map) { int i; MAP m; diff --git a/runtime/tests/ChangeLog b/runtime/tests/ChangeLog index d373c24f..5920e626 100644 --- a/runtime/tests/ChangeLog +++ b/runtime/tests/ChangeLog @@ -1,3 +1,9 @@ +2005-11-28 Martin Hunt <hunt@redhat.com> + + * pmaps/pmap.test: Add ix_log and ix_none. + * pmaps/ix_log.c: Test log histograms. + * pmaps/ix_none.c: Test no histograms. + 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_*(). diff --git a/runtime/tests/pmaps/ix_log.c b/runtime/tests/pmaps/ix_log.c new file mode 100644 index 00000000..da644d8d --- /dev/null +++ b/runtime/tests/pmaps/ix_log.c @@ -0,0 +1,62 @@ +#include "runtime.h" + +/* like ix.c, except use HIST_LOG */ +/* 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_LOG, 5); + int64_t x; + + /* 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); + } + +#if 0 + /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ + for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { + x = _stp_pmap_get_cpu_ix (map, 3); + if (x != _processor_number * _processor_number) + printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); + x = _stp_pmap_get_cpu_ix (map, 1); + if (x != _processor_number) + printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); + x = _stp_pmap_get_cpu_ix (map, 2); + if (x != 10 * _processor_number + 1) + printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); + x = _stp_pmap_get_cpu_ix (map, 4); + if (x != 1LL) + printf("ERROR: Got %lld when expected %lld\n", x, 1LL); + } +#endif + + /* 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"); + + _stp_pmap_del (map); + return 0; +} + diff --git a/runtime/tests/pmaps/ix_none.c b/runtime/tests/pmaps/ix_none.c new file mode 100644 index 00000000..c8ab6cbc --- /dev/null +++ b/runtime/tests/pmaps/ix_none.c @@ -0,0 +1,62 @@ +#include "runtime.h" + +/* like ix.c, except with no histogram */ +/* 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_NONE); + int64_t x; + + /* 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); + } + +#if 0 + /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ + for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { + x = _stp_pmap_get_cpu_ix (map, 3); + if (x != _processor_number * _processor_number) + printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); + x = _stp_pmap_get_cpu_ix (map, 1); + if (x != _processor_number) + printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); + x = _stp_pmap_get_cpu_ix (map, 2); + if (x != 10 * _processor_number + 1) + printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); + x = _stp_pmap_get_cpu_ix (map, 4); + if (x != 1LL) + printf("ERROR: Got %lld when expected %lld\n", x, 1LL); + } +#endif + + /* 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"); + + _stp_pmap_del (map); + return 0; +} + diff --git a/runtime/tests/pmaps/pmap.test b/runtime/tests/pmaps/pmap.test index cbda7baf..71f94e56 100644 --- a/runtime/tests/pmaps/pmap.test +++ b/runtime/tests/pmaps/pmap.test @@ -285,6 +285,154 @@ value |-------------------------------------------------- count } +test ix_log {Test of int64 keys and stat values (log histogram)} -setup { + exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix_log.c +} -body { + exec ./test +} -result {CPU #0 +map[1] = count:1 sum:0 avg:0 min:0 max:0 +map[2] = count:1 sum:1 avg:1 min:1 max:1 +map[3] = count:1 sum:0 avg:0 min:0 max:0 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #1 +map[1] = count:1 sum:1 avg:1 min:1 max:1 +map[2] = count:1 sum:11 avg:11 min:11 max:11 +map[3] = count:1 sum:1 avg:1 min:1 max:1 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #2 +map[1] = count:1 sum:2 avg:2 min:2 max:2 +map[2] = count:1 sum:21 avg:21 min:21 max:21 +map[3] = count:1 sum:4 avg:4 min:4 max:4 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #3 +map[1] = count:1 sum:3 avg:3 min:3 max:3 +map[2] = count:1 sum:31 avg:31 min:31 max:31 +map[3] = count:1 sum:9 avg:9 min:9 max:9 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #4 +map[1] = count:1 sum:4 avg:4 min:4 max:4 +map[2] = count:1 sum:41 avg:41 min:41 max:41 +map[3] = count:1 sum:16 avg:16 min:16 max:16 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #5 +map[1] = count:1 sum:5 avg:5 min:5 max:5 +map[2] = count:1 sum:51 avg:51 min:51 max:51 +map[3] = count:1 sum:25 avg:25 min:25 max:25 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #6 +map[1] = count:1 sum:6 avg:6 min:6 max:6 +map[2] = count:1 sum:61 avg:61 min:61 max:61 +map[3] = count:1 sum:36 avg:36 min:36 max:36 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #7 +map[1] = count:1 sum:7 avg:7 min:7 max:7 +map[2] = count:1 sum:71 avg:71 min:71 max:71 +map[3] = count:1 sum:49 avg:49 min:49 max:49 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +map[2] = count:8 sum:288 avg:36 min:1 max:71 +value |-------------------------------------------------- count + 0 | 0 + 1 |@ 1 + 2 | 0 + 4 | 0 + 8 |@@@@@@@ 7 + +map[4] = count:8 sum:8 avg:1 min:1 max:1 +value |-------------------------------------------------- count + 0 | 0 + 1 |@@@@@@@@ 8 + 2 | 0 + 4 | 0 + 8 | 0 + +map[1] = count:8 sum:28 avg:3 min:0 max:7 +value |-------------------------------------------------- count + 0 |@ 1 + 1 |@ 1 + 2 |@@ 2 + 4 |@@@@ 4 + 8 | 0 + +map[3] = count:8 sum:140 avg:17 min:0 max:49 +value |-------------------------------------------------- count + 0 |@ 1 + 1 |@ 1 + 2 | 0 + 4 |@ 1 + 8 |@@@@@ 5 + +} + +test ix_none {Test of int64 keys and stat values (no histogram)} -setup { + exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix_none.c +} -body { + exec ./test +} -result {CPU #0 +map[1] = count:1 sum:0 avg:0 min:0 max:0 +map[2] = count:1 sum:1 avg:1 min:1 max:1 +map[3] = count:1 sum:0 avg:0 min:0 max:0 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #1 +map[1] = count:1 sum:1 avg:1 min:1 max:1 +map[2] = count:1 sum:11 avg:11 min:11 max:11 +map[3] = count:1 sum:1 avg:1 min:1 max:1 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #2 +map[1] = count:1 sum:2 avg:2 min:2 max:2 +map[2] = count:1 sum:21 avg:21 min:21 max:21 +map[3] = count:1 sum:4 avg:4 min:4 max:4 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #3 +map[1] = count:1 sum:3 avg:3 min:3 max:3 +map[2] = count:1 sum:31 avg:31 min:31 max:31 +map[3] = count:1 sum:9 avg:9 min:9 max:9 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #4 +map[1] = count:1 sum:4 avg:4 min:4 max:4 +map[2] = count:1 sum:41 avg:41 min:41 max:41 +map[3] = count:1 sum:16 avg:16 min:16 max:16 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #5 +map[1] = count:1 sum:5 avg:5 min:5 max:5 +map[2] = count:1 sum:51 avg:51 min:51 max:51 +map[3] = count:1 sum:25 avg:25 min:25 max:25 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #6 +map[1] = count:1 sum:6 avg:6 min:6 max:6 +map[2] = count:1 sum:61 avg:61 min:61 max:61 +map[3] = count:1 sum:36 avg:36 min:36 max:36 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +CPU #7 +map[1] = count:1 sum:7 avg:7 min:7 max:7 +map[2] = count:1 sum:71 avg:71 min:71 max:71 +map[3] = count:1 sum:49 avg:49 min:49 max:49 +map[4] = count:1 sum:1 avg:1 min:1 max:1 + +map[2] = count:8 sum:288 avg:36 min:1 max:71 + +map[4] = count:8 sum:8 avg:1 min:1 max:1 + +map[1] = count:8 sum:28 avg:3 min:0 max:7 + +map[3] = count:8 sum:140 avg:17 min:0 max:49 + +} + test map_format {Test of map formatting and histograms} -setup { exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test map_format.c } -body { |