StropheCappuccino API 1.0.0
/tmp/tempDoc.doc/strophejs/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/uuid/benchmark/benchmark-native.c
Go to the documentation of this file.
00001 /*
00002 Test performance of native C UUID generation
00003 
00004 To Compile: cc -luuid benchmark-native.c -o benchmark-native
00005 */
00006 
00007 #include <stdio.h>
00008 #include <unistd.h>
00009 #include <sys/time.h>
00010 #include <uuid/uuid.h>
00011 
00012 int main() {
00013   uuid_t myid;
00014   char buf[36+1];
00015   int i;
00016   struct timeval t;
00017   double start, finish;
00018 
00019   gettimeofday(&t, NULL);
00020   start = t.tv_sec + t.tv_usec/1e6;
00021 
00022   int n = 2e5;
00023   for (i = 0; i < n; i++) {
00024     uuid_generate(myid);
00025     uuid_unparse(myid, buf);
00026   }
00027 
00028   gettimeofday(&t, NULL);
00029   finish = t.tv_sec + t.tv_usec/1e6;
00030   double dur = finish - start;
00031 
00032   printf("%d uuids/sec", (int)(n/dur));
00033   return 0;
00034 }
 All Classes Namespaces Files Functions Variables