WvStreams
unimem.cc
1 #include "uniconfroot.h"
2 #include <unistd.h>
3 
4 class Report
5 {
6 public:
7  const char *before;
8 
9  void ps()
10  {
11  system(WvString("ps -o pid,sz,vsz,rss,trs,drs,dsiz,cmd %s",
12  getpid()));
13  }
14 
15  Report()
16  {
17  before = (const char *)sbrk(0);
18  ps();
19  }
20 
21  void go()
22  {
23  const char *after = (const char *)sbrk(0);
24  ps();
25  printf("%p, %p, %ld\n", before, after, (long)(after-before));
26  }
27 };
28 
29 int main()
30 {
31  printf("uniconfvaluetree: %d bytes\n", sizeof(UniConfValueTree));
32  printf("wvstring: %d bytes\n", sizeof(WvString));
33  Report r;
34 
35  int mode = 2;
36  switch (mode)
37  {
38  case -1:
39  {
40  UniConfRoot uni;
41  r.go();
42  uni.mount("ini:/tmp/dns.ini2", true);
43  r.go();
44  system("touch /tmp/dns.ini2");
45  uni.refresh();
46  r.go();
47  system("touch /tmp/dns.ini2");
48  uni.refresh();
49  r.go();
50  for (int x = 0; x < 1e8; x++)
51  ;
52  system("touch /tmp/dns.ini2");
53  uni.refresh();
54  r.go();
55  }
56  break;
57  case 0:
58  {
59  UniConfRoot uni("temp:");
60  WvString s("this is a big long line with a really big "
61  "long string involved in it somehow");
62  for (int i = 0; i < 18000; i++)
63  uni.xset(WvString("blah/pah/%s", i), s.edit());
64  uni.commit();
65  r.go();
66  uni.remove();
67  uni.commit();
68  r.go();
69  }
70  break;
71  case 1:
72  {
73  WvStringList l;
74  WvString s("this is a big long line with a really big "
75  "long string involved in it somehow");
76  WvString a[18000];
77  for (int i = 0; i < 18000; i++)
78  l.append(&(a[i] = s), false);
79  r.go();
80  }
81  break;
82  case 2:
83  {
84  UniConfRoot uni("unix:/tmp/foos");
85  r.go();
86  {
88  r.go();
89  }
90  r.go();
91  }
92  }
93 
94  r.go();
95  return 0;
96 }