Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class App {
- public static void main(String[] args) {
- int nTimes = Integer.valueOf(args[1]);
- int types = Integer.valueOf(args[2]);
- Vector v = new Vector();
- for(int n = 10000; n<=1280000; n*=2){
- int[] sorted = new int[n];
- int[] inverse = new int[n];
- int[] random = new int[n];
- v.sorted(sorted);
- v.inverselySorted(inverse);
- v.random(random, n);
- long t1 = System.currentTimeMillis();
- for(int i = 0; i<nTimes; i++){
- Bubble1.bubble(sorted);
- }
- long t2 = System.currentTimeMillis();
- System.out.println("Bubble sorted time: "+(t1-t2));
- t1 = System.currentTimeMillis();
- for(int i = 0; i<nTimes; i++){
- Bubble1.bubble(inverse);
- }
- t2 = System.currentTimeMillis();
- System.out.println("Bubble inverse time: "+(t1-t2));
- t1 = System.currentTimeMillis();
- for(int i = 0; i<nTimes; i++){
- Bubble1.bubble(random);
- }
- t2 = System.currentTimeMillis();
- System.out.println("Bubble random time: "+(t1-t2));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment