Package cern.colt

Examples of cern.colt.Timer


  try { Thread.currentThread().sleep(1000); } catch (InterruptedException exc) {};
 

  System.out.println("Now benchmarking...");
  int s=0;
  Timer timer0 = new Timer();
  Timer timer1 = new Timer();
  Timer timer2 = new Timer();
  //map.hashCollisions = 0;
  for (int run=runs; --run >=0; ) {
    if (kind.equals("add")) {
      map.clear();
      //map.ensureCapacity(size*3);
      timer0.start();
      for (int i=size; --i >=0; ) {
        map.put(i,i);
      }
      timer0.stop();
    }
    if (kind.equals("get")) {
      timer0.start();
      for (int i=size; --i >=0; ) {
        s += map.get(i);
      }
      timer0.stop();
    }
    else {
      timer1.start();
      map.rehash(PrimeFinder.nextPrime(size*2));
      timer1.stop();

      timer2.start();
      map.rehash(PrimeFinder.nextPrime((int) (size*1.5)));
      timer2.stop();
    }
  }

  System.out.println("adding: "+timer0);
  System.out.println("growing: "+timer1);
View Full Code Here


  //  System.out.println("Computing b's and k's for KNOWN N");
  //else
  //  System.out.println("Computing b's and k's for UNKNOWN N");
  System.out.println("mem [Math.round(elements/1000.0)]");
  System.out.println("***********************************");
  Timer timer = new Timer().start();

  for (int q=0; q<quantiles.length; q++) {
    int p = quantiles[q];
    System.out.println("------------------------------");
    System.out.println("computing for p = "+p);
    for (int s=0; s<sizes.length; s++) {
      long N = sizes[s];
      System.out.println("   ------------------------------");
      System.out.println("   computing for N = "+N);
      for (int e=0; e<epsilons.length; e++) {
        double epsilon = epsilons[e];
        System.out.println("      ------------------------------");
        System.out.println("      computing for e = "+epsilon);
        for (int d=0; d<deltas.length; d++) {
          double delta = deltas[d];
          for (int knownCounter=0; knownCounter<2; knownCounter++) {
            boolean known_N;
            if (knownCounter ==0) known_N = true;
            else known_N = false;

            DoubleQuantileFinder finder = QuantileFinderFactory.newDoubleQuantileFinder(known_N, N, epsilon, delta, p, null);
            //System.out.println(finder.getClass().getName());
            /*
            double[] returnSamplingRate = new double[1];
            long[] result;
            if (known_N) {
              result = QuantileFinderFactory.known_N_compute_B_and_K(N, epsilon, delta, p, returnSamplingRate);
            }
            else {
              result = QuantileFinderFactory.unknown_N_compute_B_and_K(epsilon, delta, p);
              long b1 = result[0];
              long k1 = result[1];

              if (N>=0) {
                long[] resultKnown = QuantileFinderFactory.known_N_compute_B_and_K(N, epsilon, delta, p, returnSamplingRate);
                long b2 = resultKnown[0];
                long k2 = resultKnown[1];
       
                if (b2 * k2 < b1 * k1) { // the KnownFinder is smaller
                  result = resultKnown;
                }
              }
            }
           

            long b = result[0];
            long k = result[1];
            */
            String knownStr = known_N ? "  known" : "unknown";
            long mem = finder.totalMemory();
            if (mem==0) mem = N;
            //else if (mem==0 && !known_N && N<0) mem = Long.MAX_VALUE; // actually infinity
            //else if (mem==0 && !known_N && N>=0) mem = N;
            //System.out.print("         (e,d,N,p)=("+epsilon+","+delta+","+N+","+p+") --> ");
            System.out.print("         (known, d)=("+knownStr+", "+delta+") --> ");
            //System.out.print("(mem,b,k,memF");
            System.out.print("(MB,mem");
            //if (known_N) System.out.print(",sampling");
            //System.out.print(")=("+(Math.round(b*k/1000.0))+","+b+","+k+", "+Math.round(b*k*8/1024.0/1024.0));
            //System.out.print(")=("+b*k/1000.0+","+b+","+k+", "+b*k*8/1024.0/1024.0+", "+Math.round(b*k*8/1024.0/1024.0));
            System.out.print(")=("+mem*8.0/1024.0/1024.0+",  "+mem/1000.0+",  "+Math.round(mem*8.0/1024.0/1024.0));
            //if (known_N) System.out.print(","+returnSamplingRate[0]);
            System.out.println(")");
          }
        }
      }
    }
  }

  timer.stop().display();
}
View Full Code Here

    }
  }
  System.out.println(timer.stop());
  */
 
  Timer timer = new Timer().start();
  DoubleBuffer buffer;
  int val;
  double f;
  int j;

  for (int i=0; i<size; i++) {
    for (j=0; j<size; j++) {
      buffer=null;
      val=10;
      f=1.0f;
    }
  }
  System.out.println(timer.stop());

  System.out.println("free="+Runtime.getRuntime().freeMemory());
  System.out.println("total="+Runtime.getRuntime().totalMemory());
}
View Full Code Here

  System.out.println("total="+Runtime.getRuntime().totalMemory());

  double[] phis = {0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999, 1.0};
  //int quantiles = phis.length;

  Timer timer = new Timer();
  Timer timer2 = new Timer();
  DoubleQuantileFinder approxFinder;

  approxFinder = QuantileFinderFactory.newDoubleQuantileFinder(false, max_N, epsilon, delta, quantiles, null);
  System.out.println(approxFinder);
  //new UnknownApproximateDoubleQuantileFinder(b,k);
  //approxFinder = new ApproximateDoubleQuantileFinder(b,k);
  /*
  double[] returnSamplingRate = new double[1];
  long[] result = ApproximateQuantileFinder.computeBestBandK(size*chunks, epsilon, delta, quantiles, returnSamplingRate);
  approxFinder = new ApproximateQuantileFinder((int) result[0], (int) result[1]);
  System.out.println("epsilon="+epsilon);
  System.out.println("delta="+delta);
  System.out.println("samplingRate="+returnSamplingRate[0]);
  */

   
  DoubleQuantileFinder exactFinder = QuantileFinderFactory.newDoubleQuantileFinder(false, -1, 0.0, delta, quantiles, null);
  System.out.println(exactFinder);

  DoubleArrayList list = new DoubleArrayList(size);

  for (int chunk=0; chunk<chunks; chunk++) {
    list.setSize(0);
    int d = chunk*size;
    timer2.start();
    for (int i=0; i<size; i++) {
      list.add((double)(i + d));
    }
    timer2.stop();
   

   
    //System.out.println("unshuffled="+list);
    if (doShuffle) {
      Timer timer3 = new Timer().start();
      list.shuffle();
      System.out.println("shuffling took ");
      timer3.stop().display();
    }
    //System.out.println("shuffled="+list);
    //list.sort();
    //System.out.println("sorted="+list);

View Full Code Here

  try { Thread.currentThread().sleep(1000); } catch (InterruptedException exc) {};
 

  System.out.println("Now benchmarking...");
  int s=0;
  Timer timer0 = new Timer();
  Timer timer1 = new Timer();
  Timer timer2 = new Timer();
  //map.hashCollisions = 0;
  for (int run=runs; --run >=0; ) {
    if (kind.equals("add")) {
      map.clear();
      //map.ensureCapacity(size*3);
      timer0.start();
      for (int i=size; --i >=0; ) {
        map.put(i,i);
      }
      timer0.stop();
    }
    if (kind.equals("get")) {
      timer0.start();
      for (int i=size; --i >=0; ) {
        s += map.get(i);
      }
      timer0.stop();
    }
    else {
      timer1.start();
      map.rehash(PrimeFinder.nextPrime(size*2));
      timer1.stop();

      timer2.start();
      map.rehash(PrimeFinder.nextPrime((int) (size*1.5)));
      timer2.stop();
    }
  }

  System.out.println("adding: "+timer0);
  System.out.println("growing: "+timer1);
View Full Code Here

  //  System.out.println("Computing b's and k's for KNOWN N");
  //else
  //  System.out.println("Computing b's and k's for UNKNOWN N");
  System.out.println("mem [Math.round(elements/1000.0)]");
  System.out.println("***********************************");
  Timer timer = new Timer().start();

  for (int q=0; q<quantiles.length; q++) {
    int p = quantiles[q];
    System.out.println("------------------------------");
    System.out.println("computing for p = "+p);
    for (int s=0; s<sizes.length; s++) {
      long N = sizes[s];
      System.out.println("   ------------------------------");
      System.out.println("   computing for N = "+N);
      for (int e=0; e<epsilons.length; e++) {
        double epsilon = epsilons[e];
        System.out.println("      ------------------------------");
        System.out.println("      computing for e = "+epsilon);
        for (int d=0; d<deltas.length; d++) {
          double delta = deltas[d];
          for (int knownCounter=0; knownCounter<2; knownCounter++) {
            boolean known_N;
            if (knownCounter ==0) known_N = true;
            else known_N = false;

            DoubleQuantileFinder finder = QuantileFinderFactory.newDoubleQuantileFinder(known_N, N, epsilon, delta, p, null);
            //System.out.println(finder.getClass().getName());
            /*
            double[] returnSamplingRate = new double[1];
            long[] result;
            if (known_N) {
              result = QuantileFinderFactory.known_N_compute_B_and_K(N, epsilon, delta, p, returnSamplingRate);
            }
            else {
              result = QuantileFinderFactory.unknown_N_compute_B_and_K(epsilon, delta, p);
              long b1 = result[0];
              long k1 = result[1];

              if (N>=0) {
                long[] resultKnown = QuantileFinderFactory.known_N_compute_B_and_K(N, epsilon, delta, p, returnSamplingRate);
                long b2 = resultKnown[0];
                long k2 = resultKnown[1];
       
                if (b2 * k2 < b1 * k1) { // the KnownFinder is smaller
                  result = resultKnown;
                }
              }
            }
           

            long b = result[0];
            long k = result[1];
            */
            String knownStr = known_N ? "  known" : "unknown";
            long mem = finder.totalMemory();
            if (mem==0) mem = N;
            //else if (mem==0 && !known_N && N<0) mem = Long.MAX_VALUE; // actually infinity
            //else if (mem==0 && !known_N && N>=0) mem = N;
            //System.out.print("         (e,d,N,p)=("+epsilon+","+delta+","+N+","+p+") --> ");
            System.out.print("         (known, d)=("+knownStr+", "+delta+") --> ");
            //System.out.print("(mem,b,k,memF");
            System.out.print("(MB,mem");
            //if (known_N) System.out.print(",sampling");
            //System.out.print(")=("+(Math.round(b*k/1000.0))+","+b+","+k+", "+Math.round(b*k*8/1024.0/1024.0));
            //System.out.print(")=("+b*k/1000.0+","+b+","+k+", "+b*k*8/1024.0/1024.0+", "+Math.round(b*k*8/1024.0/1024.0));
            System.out.print(")=("+mem*8.0/1024.0/1024.0+",  "+mem/1000.0+",  "+Math.round(mem*8.0/1024.0/1024.0));
            //if (known_N) System.out.print(","+returnSamplingRate[0]);
            System.out.println(")");
          }
        }
      }
    }
  }

  timer.stop().display();
}
View Full Code Here

    }
  }
  System.out.println(timer.stop());
  */
 
  Timer timer = new Timer().start();
  DoubleBuffer buffer;
  int val;
  double f;
  int j;

  for (int i=0; i<size; i++) {
    for (j=0; j<size; j++) {
      buffer=null;
      val=10;
      f=1.0f;
    }
  }
  System.out.println(timer.stop());

  System.out.println("free="+Runtime.getRuntime().freeMemory());
  System.out.println("total="+Runtime.getRuntime().totalMemory());
}
View Full Code Here

  System.out.println("total="+Runtime.getRuntime().totalMemory());

  double[] phis = {0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999, 1.0};
  //int quantiles = phis.length;

  Timer timer = new Timer();
  Timer timer2 = new Timer();
  DoubleQuantileFinder approxFinder;

  approxFinder = QuantileFinderFactory.newDoubleQuantileFinder(false, max_N, epsilon, delta, quantiles, null);
  System.out.println(approxFinder);
  //new UnknownApproximateDoubleQuantileFinder(b,k);
  //approxFinder = new ApproximateDoubleQuantileFinder(b,k);
  /*
  double[] returnSamplingRate = new double[1];
  long[] result = ApproximateQuantileFinder.computeBestBandK(size*chunks, epsilon, delta, quantiles, returnSamplingRate);
  approxFinder = new ApproximateQuantileFinder((int) result[0], (int) result[1]);
  System.out.println("epsilon="+epsilon);
  System.out.println("delta="+delta);
  System.out.println("samplingRate="+returnSamplingRate[0]);
  */

   
  DoubleQuantileFinder exactFinder = QuantileFinderFactory.newDoubleQuantileFinder(false, -1, 0.0, delta, quantiles, null);
  System.out.println(exactFinder);

  DoubleArrayList list = new DoubleArrayList(size);

  for (int chunk=0; chunk<chunks; chunk++) {
    list.setSize(0);
    int d = chunk*size;
    timer2.start();
    for (int i=0; i<size; i++) {
      list.add((double)(i + d));
    }
    timer2.stop();
   

   
    //System.out.println("unshuffled="+list);
    if (doShuffle) {
      Timer timer3 = new Timer().start();
      list.shuffle();
      System.out.println("shuffling took ");
      timer3.stop().display();
    }
    //System.out.println("shuffled="+list);
    //list.sort();
    //System.out.println("sorted="+list);

View Full Code Here

TOP

Related Classes of cern.colt.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.