"Fossies" - the Fresh Open Source Software Archive

Member "ical-tcl/types/hspeed.C" (15 Apr 2019, 762 Bytes) of package /linux/privat/ical-3.0.4.tar.gz:


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 /* Copyright (c) 1996  by Sanjay Ghemawat */
    2 // Speed tests for the hashed map
    3 
    4 #include <iostream.h>
    5 
    6 #include <stdio.h>
    7 #include <string.h>
    8 #include <stdlib.h>
    9 #include <math.h>
   10 #include <sys/time.h>
   11 
   12 #include "longmap.h"
   13 
   14 main(int argc, char *argv[]) {
   15     LongMap m;
   16     m.predict(100);
   17     int size = 20000;
   18     int reps;
   19     int count = 0;
   20     if (argc < 2 || argc > 3) {
   21         fprintf(stderr, "Usage: %s <repetitions> [<size>]\n", argv[0]);
   22         exit(EXIT_FAILURE);
   23     }
   24     srand48(time(0));
   25     reps = atoi(argv[1]);
   26     if (argc == 3) size = atoi(argv[2]);
   27     for (long i = 0; i < reps; i++) {
   28         long j1 = i%size, j2 = size - j1;
   29         m.insert(j1, i);
   30         m.remove(j2);
   31     }
   32     m.report_stats("table");
   33     return EXIT_SUCCESS;
   34 }