File: speed7.c

package info (click to toggle)
whitedb 0.7.3%2Bgit200711-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 3,340 kB
  • sloc: ansic: 33,250; javascript: 3,299; python: 790; lex: 359; java: 277; makefile: 192; sh: 164; yacc: 138; sed: 41
file content (34 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (8)
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
/*
creating and immediately filling with string data 
1 million records of 5 fields in a 1 GIG database:
the string is 100 bytes long and is encoded each time.

real	0m1.464s
user	0m1.446s
sys	0m0.017s

*/

#include <whitedb/dbapi.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv) {
  void *db, *rec;
  char *name="7";
  int i,j;
  char* content="0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
  db = wg_attach_database(name, 1000000000);
  if (!db) { printf("db creation failed \n"); exit(0); }
  for(i=0;i<1000000;i++) {   
    rec = wg_create_raw_record(db, 5);
    if (!rec) { printf("record creation failed \n"); exit(0); }      
    for (j=0;j<5;j++) {
      wg_set_new_field(db,rec,j,wg_encode_str(db,content,NULL));      
    }
  }  
  printf("i %d \n", i);
  wg_detach_database(db);
  wg_delete_database(name);
  return 0;
}