polectron

Untitled

Feb 21st, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1.  
  2. public class App {
  3.  
  4. public static void main(String[] args) {
  5.  
  6. int nTimes = Integer.valueOf(args[1]);
  7. int types = Integer.valueOf(args[2]);
  8.  
  9. Vector v = new Vector();
  10.  
  11. for(int n = 10000; n<=1280000; n*=2){
  12. int[] sorted = new int[n];
  13. int[] inverse = new int[n];
  14. int[] random = new int[n];
  15.  
  16. v.sorted(sorted);
  17. v.inverselySorted(inverse);
  18. v.random(random, n);
  19.  
  20. long t1 = System.currentTimeMillis();
  21. for(int i = 0; i<nTimes; i++){
  22. Bubble1.bubble(sorted);
  23. }
  24. long t2 = System.currentTimeMillis();
  25. System.out.println("Bubble sorted time: "+(t1-t2));
  26.  
  27. t1 = System.currentTimeMillis();
  28. for(int i = 0; i<nTimes; i++){
  29. Bubble1.bubble(inverse);
  30. }
  31. t2 = System.currentTimeMillis();
  32. System.out.println("Bubble inverse time: "+(t1-t2));
  33.  
  34. t1 = System.currentTimeMillis();
  35. for(int i = 0; i<nTimes; i++){
  36. Bubble1.bubble(random);
  37. }
  38. t2 = System.currentTimeMillis();
  39. System.out.println("Bubble random time: "+(t1-t2));
  40. }
  41.  
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment