package watki.podstawy;

import java.util.Random;

public class SumaTablicy0 {

	public static void main(String[] args) {
		final int N = 200_000_000;
		final int MAX = 1000;
		System.out.println("Tworzę tablicę i losuję liczby");
		
		Random random = new Random();
		int[] t = new int[N];
		
		for(int i = 0; i < t.length; i++) {
			t[i] = random.nextInt(MAX);
		}

		System.out.println("Liczę sumę");
		long p = System.nanoTime();
		long suma = 0;
		for(int i = 0; i < t.length; i++) {
			suma += t[i];
		}
		long k = System.nanoTime();
		System.out.printf("suma: %d, czas: %.3f s\n", suma, (k - p)/1e9);
	}

}
