Skip to content

Instantly share code, notes, and snippets.

@tanzaku
Created February 17, 2018 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanzaku/6bb7dc20468f53bce6f20da7fd1e805f to your computer and use it in GitHub Desktop.
Save tanzaku/6bb7dc20468f53bce6f20da7fd1e805f to your computer and use it in GitHub Desktop.
ForkJoinPool memo
public static void main(String[] args) throws InterruptedException, ExecutionException {
int seedStart = 1000;
int testcase = 100;
ForkJoinPool forkJoinPool = new ForkJoinPool(6);
double[] res = forkJoinPool.submit(() ->
IntStream.range(seedStart, seedStart + testcase)
.parallel()
.mapToDouble(s -> new PointsOnTheCircleVis().runTest(s+""))
.toArray()
).get();
double sum = 0;
for (int i = 0; i < res.length; i++) {
sum += res[i];
// System.err.println((seedStart + i) + "," + res[i]);
}
System.err.println(sum);
for (int i = 0; i < res.length; i++) {
System.err.println(res[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment