Java Code Examples for java.util.concurrent.ForkJoinPool#getStealCount()

The following examples show how to use java.util.concurrent.ForkJoinPool#getStealCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NQueensCS.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 15);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }
}
 
Example 2
Source File: NQueensCS.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 3
Source File: NQueensCS.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 15);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }
}
 
Example 4
Source File: NQueensCS.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 15);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }
}
 
Example 5
Source File: NQueensCS.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 15);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }
}
 
Example 6
Source File: NQueensCS.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 7
Source File: NQueensCS.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 8
Source File: NQueensCS.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 9
Source File: NQueensCS.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 15);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }
}
 
Example 10
Source File: NQueensCS.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 11
Source File: NQueensCS.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 15);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }
}
 
Example 12
Source File: NQueensCS.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 13
Source File: NQueensCS.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 15);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }
}
 
Example 14
Source File: NQueensCS.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 15
Source File: NQueensCS.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 16
Source File: NQueensCS.java    From native-obfuscator with GNU General Public License v3.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 17
Source File: NQueensCS.java    From native-obfuscator with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Usage: NQueensCS [minBoardSize=N] [maxBoardSize=N] [procs=N] [reps=N]
 */
public static void main(String[] args) throws Exception {
    // Board sizes too small: hard to measure well.
    // Board sizes too large: take too long to run.
    final int minBoardSize = intArg(args, "minBoardSize",  8);
    final int maxBoardSize = intArg(args, "maxBoardSize", 11);

    final int procs = intArg(args, "procs", 0);

    for (int reps = intArg(args, "reps", 1); reps > 0; reps--) {
        ForkJoinPool g = (procs == 0) ?
            new ForkJoinPool() :
            new ForkJoinPool(procs);
        lastStealCount = g.getStealCount();
        for (int i = minBoardSize; i <= maxBoardSize; i++)
            test(g, i);
        System.out.println(g);
        g.shutdown();
    }

    System.out.println("Passed = 1, failed = 0");
}
 
Example 18
Source File: NQueensCS.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 19
Source File: NQueensCS.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void test(ForkJoinPool g, int i) throws Exception {
    boardSize = i;
    int ps = g.getParallelism();
    long start = System.nanoTime();
    NQueensCS task = new NQueensCS(new int[0]);
    g.invoke(task);
    int solutions = task.solutions;
    long time = System.nanoTime() - start;
    double secs = (double) time / NPS;
    if (solutions != expectedSolutions[i])
        throw new Error();
    System.out.printf("NQueensCS %3d", i);
    System.out.printf(" Time: %7.3f", secs);
    long sc = g.getStealCount();
    long ns = sc - lastStealCount;
    lastStealCount = sc;
    System.out.printf(" Steals/t: %5d", ns/ps);
    System.out.println();
}
 
Example 20
Source File: PrimeNumbersUnitManualTest.java    From tutorials with MIT License 5 votes vote down vote up
private void stealCountInfo(StringBuilder info, int granularity, ForkJoinPool forkJoinPool) {
    PrimeNumbers primes = new PrimeNumbers(1, 10000, granularity, new AtomicInteger(0));
    forkJoinPool.invoke(primes);
    forkJoinPool.shutdown();

    long steals = forkJoinPool.getStealCount();
    String output = "\nGranularity: [" + granularity + "], Steals: [" + steals + "]";
    info.append(output);
}