WvStreams
unimem.cc
00001 #include "uniconfroot.h"
00002 #include <unistd.h>
00003 
00004 class Report
00005 {
00006 public:
00007     const char *before;
00008     
00009     void ps()
00010     {
00011         system(WvString("ps -o pid,sz,vsz,rss,trs,drs,dsiz,cmd %s",
00012                         getpid()));
00013     }
00014     
00015     Report()
00016     {
00017         before = (const char *)sbrk(0);
00018         ps();
00019     }
00020     
00021     void go()
00022     {
00023         const char *after = (const char *)sbrk(0);
00024         ps();
00025         printf("%p, %p, %ld\n", before, after, (long)(after-before));
00026     }
00027 };
00028 
00029 int main()
00030 {
00031     printf("uniconfvaluetree: %d bytes\n", sizeof(UniConfValueTree));
00032     printf("wvstring: %d bytes\n", sizeof(WvString));
00033     Report r;
00034 
00035     int mode = 2;
00036     switch (mode)
00037     {
00038     case -1:
00039         {
00040             UniConfRoot uni;
00041             r.go();
00042             uni.mount("ini:/tmp/dns.ini2", true);
00043             r.go();
00044             system("touch /tmp/dns.ini2");
00045             uni.refresh();
00046             r.go();
00047             system("touch /tmp/dns.ini2");
00048             uni.refresh();
00049             r.go();
00050             for (int x = 0; x < 1e8; x++)
00051                 ;
00052             system("touch /tmp/dns.ini2");
00053             uni.refresh();
00054             r.go();
00055         }
00056         break;
00057     case 0:
00058         {
00059             UniConfRoot uni("temp:");
00060             WvString s("this is a big long line with a really big "
00061                        "long string involved in it somehow");
00062             for (int i = 0; i < 18000; i++)
00063                 uni.xset(WvString("blah/pah/%s", i), s.edit());
00064             uni.commit();
00065             r.go();
00066             uni.remove();
00067             uni.commit();
00068             r.go();
00069         }
00070         break;
00071     case 1:
00072         {
00073             WvStringList l;
00074             WvString s("this is a big long line with a really big "
00075                        "long string involved in it somehow");
00076             WvString a[18000];
00077             for (int i = 0; i < 18000; i++)
00078                 l.append(&(a[i] = s), false);
00079             r.go();
00080         }
00081         break;
00082     case 2:
00083         {
00084             UniConfRoot uni("unix:/tmp/foos");
00085             r.go();
00086             {
00087                 UniConf::RecursiveIter i(uni);
00088                 r.go();
00089             }
00090             r.go();
00091         }
00092     }
00093 
00094     r.go();
00095     return 0;
00096 }