16 int main(int argc, char ** argv)
20 int bufsiz = atoi(argv[1]);
21 int numpoints = atoi(argv[2]);
23 DataPoint * buffer = (DataPoint*)(calloc(bufsiz, sizeof(DataPoint)));
28 sqlite3_open("sqlite.db", &db);
32 char * query_value = query+sprintf(query,"insert into sensor values(");
35 struct timeval start_time;
36 gettimeofday(&start_time, NULL);
42 for (j = 0; j < bufsiz && i < numpoints; ++j)
49 for (int k = 0; k < j; ++k)
51 sprintf(query_value,"%f,%f)", buffer[k].time, buffer[k].value);
52 sqlite3_exec(db, query, NULL, NULL, NULL);
56 struct timeval end_time;
57 gettimeofday(&end_time, NULL);
62 float time_elapsed = (float)(end_time.tv_sec - start_time.tv_sec) + 1e-6*(end_time.tv_usec - start_time.tv_usec);
63 printf("%f\n", time_elapsed);