"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/node-uuid/benchmark/benchmark-native.c" (7 Feb 2017, 613 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2 Test performance of native C UUID generation
    3 
    4 To Compile: cc -luuid benchmark-native.c -o benchmark-native
    5 */
    6 
    7 #include <stdio.h>
    8 #include <unistd.h>
    9 #include <sys/time.h>
   10 #include <uuid/uuid.h>
   11 
   12 int main() {
   13   uuid_t myid;
   14   char buf[36+1];
   15   int i;
   16   struct timeval t;
   17   double start, finish;
   18 
   19   gettimeofday(&t, NULL);
   20   start = t.tv_sec + t.tv_usec/1e6;
   21 
   22   int n = 2e5;
   23   for (i = 0; i < n; i++) {
   24     uuid_generate(myid);
   25     uuid_unparse(myid, buf);
   26   }
   27 
   28   gettimeofday(&t, NULL);
   29   finish = t.tv_sec + t.tv_usec/1e6;
   30   double dur = finish - start;
   31 
   32   printf("%d uuids/sec", (int)(n/dur));
   33   return 0;
   34 }