summaryrefslogtreecommitdiffstats
path: root/runtime/tests/maps/ist.c
blob: be3ca87d778d47b1e98e0d0d99ca727a156f3b3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "runtime.h"

/* test of maps with keys of int64 and value of stat */

#define KEY1_TYPE INT64
#include "map-keys.c"

#define VALUE_TYPE STAT
#include "map-values.c"

#include "map.c"

int main ()
{
  int i, j;
  MAP map = _stp_map_new_int64(4, HSTAT_LINEAR, 0, 100, 10 );
  MAP map2 = _stp_map_new_int64(4, HSTAT_LOG, 11);

  _stp_map_key_int64 (map, 3);
  for (i = 0; i < 100; i++)
    for (j = 0; j <= i*10 ; j++ )
      _stp_map_add_int64_stat (map, i);

  _stp_map_key_int64 (map, 2);
  for (i = 0; i < 10; i++)
    for (j = 0; j < 10 ; j++ )
      _stp_map_add_int64_stat (map, j * i );

  _stp_map_key_int64 (map, 1);
  for (i = 0; i < 100; i += 10)
    for (j = 0; j < i/10 ; j++ )  
      _stp_map_add_int64_stat (map, i);

  _stp_map_key_int64 (map2, 1);
  for (i = 0; i < 128; i++)
    for (j = 0; j < 128 ; j++ )
      _stp_map_add_int64_stat (map2, i);      

  _stp_map_key_int64 (map2, 2);
  for (i = 0; i < 1024; i++)
    for (j = 0; j < 1024 ; j++ )
      _stp_map_add_int64_stat (map2, i);      

  _stp_map_print (map, "map[%1d] = count:%C  sum:%S  avg:%A  min:%m  max:%M\n%H");
  _stp_map_print (map2, "map2[%1d] = count:%C  sum:%S  avg:%A  min:%m  max:%M\n%H");

  _stp_map_del (map);
  _stp_map_del (map2);
  return 0;
}