Skip to content

Instantly share code, notes, and snippets.

@vbezhenar
Created November 18, 2015 19:49
Show Gist options
  • Save vbezhenar/d3bd0848c1648d2f2561 to your computer and use it in GitHub Desktop.
Save vbezhenar/d3bd0848c1648d2f2561 to your computer and use it in GitHub Desktop.
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