Created
November 18, 2015 19:49
-
-
Save vbezhenar/d3bd0848c1648d2f2561 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
public class Test { | |
public static void main(String[] args) throws Exception { | |
int[] ns = {1_000_000, 5_000_000, 10_000_000, 25_000_000, 50_000_000, 100_000_000, 500_000_000}; | |
for (int n : ns) { | |
for (int counter = 5; counter --> 0;) { | |
float[] a = new float[n]; | |
for (int i = 0; i < n; i++) | |
a[i] = (float) Math.random(); | |
long t_start = System.currentTimeMillis(); | |
for (int i = 0; i < a.length; i++) | |
a[i] = a[i] >= 0.5 ? 1.0f : 0.0f; | |
long elapsed = System.currentTimeMillis() - t_start; | |
System.out.printf("%10d %6d%n", n, elapsed); | |
System.gc(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment