
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author davereed
 */
public class ListCompare {

    private final static int NUM_REPS = 1000;

    public static void main(String[] args) {
        StopWatch watch = new StopWatch();

        System.out.print("Enter the list size: ");
        Scanner input = new Scanner(System.in);

        int size = input.nextInt();

        for (int rep = 0; rep < 10; rep++) {
            ArrayList<Integer> numsArr = new ArrayList<Integer>();
            for (int i = 0; i < size; i++) {
                numsArr.add(0);
            }

            watch.start();

            for (int i = 0; i < ListCompare.NUM_REPS; i++) {
                numsArr.get(numsArr.size()/2);
            }
            watch.stop();
            System.out.print(size + ": " + (double) watch.getElapsedTime());

            LinkedList<Integer> numsLink = new LinkedList<Integer>();
            for (int i = 0; i < size; i++) {
                numsLink.add(0);
            }

            watch.start();
            for (int i = 0; i < ListCompare.NUM_REPS; i++) {
                numsLink.get(numsLink.size()/2);
            }
            watch.stop();
            System.out.println(" " + (double) watch.getElapsedTime());

            size *= 2;
        }
    }
}
