WvStreams
unimem.cc
1#include "uniconfroot.h"
2#include <unistd.h>
3
4class Report
5{
6public:
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
29int 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 {
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}
Definition: unimem.cc:5
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...
Definition: uniconfroot.h:74
A plain UniConfTree that holds keys and values.
Definition: uniconftree.h:153
This iterator performs depth-first traversal of a subtree.
Definition: uniconf.h:467
void commit() const
Commits information about this key recursively.
Definition: uniconf.cc:125
void remove() const
Removes this key and all of its children from the registry.
Definition: uniconf.h:232
void xset(WvStringParm key, WvStringParm value) const
A different way to say cfg[x].setme(y).
Definition: uniconf.h:199
bool refresh() const
Refreshes information about this key recursively.
Definition: uniconf.cc:119
IUniConfGen * mount(WvStringParm moniker, bool refresh=true) const
Mounts a generator at this key using a moniker.
Definition: uniconf.cc:131
This is a WvList of WvStrings, and is a really handy way to parse strings.
Definition: wvstringlist.h:28
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:330
char * edit()
make the string editable, and return a non-const (char*)
Definition: wvstring.h:397