]> sourceware.org Git - systemtap.git/commitdiff
2005-11-28 Martin Hunt <hunt@redhat.com>
authorhunt <hunt>
Mon, 28 Nov 2005 20:08:09 +0000 (20:08 +0000)
committerhunt <hunt>
Mon, 28 Nov 2005 20:08:09 +0000 (20:08 +0000)
* map-stat.c (_stp_pmap_new_hstat_log): Fix typo. Call
_stp_pmap_new() instead of _stp_map_new().

runtime/ChangeLog
runtime/map-stat.c
runtime/tests/ChangeLog
runtime/tests/pmaps/ix_log.c [new file with mode: 0644]
runtime/tests/pmaps/ix_none.c [new file with mode: 0644]
runtime/tests/pmaps/pmap.test

index 8df9ac99a29bb0eb1ed8b8938c3b3a52461e35f9..01a28730d10180fc5f582010196cfce1338c595d 100644 (file)
@@ -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.
index 7d4e72aac10b501de2e7dcbb2846a2e4e40d54c6..51377d00caa0efe95752764f749a4f3b7317416a 100644 (file)
@@ -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;
index d373c24ff8593b259ca57d049b4c811de77f9c82..5920e626326f0ede5e34b590ce7a39682e9eaf3f 100644 (file)
@@ -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 (file)
index 0000000..da644d8
--- /dev/null
@@ -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 (file)
index 0000000..c8ab6cb
--- /dev/null
@@ -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;
+}
+
index cbda7bafb238e027edef5acc9418341f78d95182..71f94e56c377bb487f79466206daa487ec776b58 100644 (file)
@@ -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 {
This page took 0.033103 seconds and 5 git commands to generate.