stew

a monorepo of some sort
git clone git://git.nsmpr.xyz/stew.git
Log | Files | Refs

wdbstress.c (799B)


      1 /*
      2 	Create n files, then read n entries in wdb keyval store;
      3 	measure time.
      4 */
      5 
      6 #include <u.h>
      7 #include <libc.h>
      8 
      9 int fd;
     10 char buf[256];
     11 
     12 void
     13 create1(char *key)
     14 {
     15 	fprint(fd, "store %s %s", key, "uhehe guhehe\n");
     16 	read(fd, buf, 256);
     17 }
     18 
     19 void
     20 read1(char *key)
     21 {
     22 	fprint(fd, "fetch %s %s", key, "uhehe guhehe\n");
     23 	read(fd, buf, 256);
     24 }
     25 
     26 void
     27 main(int argc, char **argv)
     28 {
     29 	long t[2], b[4];
     30 	if (argc < 2) exits("no arg");
     31 	long i, l = strtol(argv[1], nil, 10);
     32 	fd = open("/srv/wdb", ORDWR);
     33 	t[0] = times(b);
     34 	for (i = 0; i < l; i++) {
     35 		snprint(buf, 256, "%ld", i);
     36 		create1(buf);
     37 	}
     38 	t[1] = times(b);
     39 	print("create: %ld ms\n", t[1] - t[0]);
     40 	t[0] = times(b);
     41 	for (i = 0; i < l; i++) {
     42 		snprint(buf, 256, "%ld", i);
     43 		read1(buf);
     44 	}
     45 	t[1] = times(b);
     46 	print("read: %ld ms\n", t[1] - t[0]);
     47 }