Package edu.umd.cloud9.util.benchmark

Source Code of edu.umd.cloud9.util.benchmark.BenchmarkFibonacciHeapInt

package edu.umd.cloud9.util.benchmark;

import java.util.Random;

import edu.umd.cloud9.util.FibonacciHeapInt;

public class BenchmarkFibonacciHeapInt {
  public static void main(String[] args) {
    FibonacciHeapInt heap = new FibonacciHeapInt();
    Random r = new Random();

    long startTime;
    long endTime;

    startTime = System.currentTimeMillis();
    for (int i = 0; i < 1000000; i++) {
      int n = r.nextInt(1000);
      float f = r.nextFloat();

      heap.insert(n, f);
    }

    endTime = System.currentTimeMillis();
    System.out.println("inserts completed in " + (endTime - startTime) + " ms");

    long sum = 0;
    startTime = System.currentTimeMillis();
    for (int i = 0; i < 500000; i++) {
      sum += heap.removeMin().getDatum();
    }
    endTime = System.currentTimeMillis();
    System.out.println("mins completed in " + (endTime - startTime) + " ms");
  }
}
TOP

Related Classes of edu.umd.cloud9.util.benchmark.BenchmarkFibonacciHeapInt

TOP
Copyright © 2018 www.massapi.com. 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.