lib.Stopwatch.start()

Here are the examples of the java api lib.Stopwatch.start() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

8 Source : LockedNeighborCandidateTest.java
with MIT License
from knewjade

@Test
void random() {
    int maxClearLine = 3;
    LockedCandidate candidate1 = createLockedCandidate(maxClearLine);
    LockedNeighborCandidate candidate2 = createLockedNeighborCandidate(maxClearLine);
    MinoShifter minoShifter = new MinoShifter();
    Stopwatch stopwatch1 = Stopwatch.createStartedStopwatch();
    Stopwatch stopwatch2 = Stopwatch.createStartedStopwatch();
    Randoms randoms = new Randoms();
    for (int count = 0; count < 10000; count++) {
        Field field = randoms.field(maxClearLine, 7);
        for (Piece piece : Piece.values()) {
            // LockedCandidate
            stopwatch1.start();
            Set<Action> search1 = candidate1.search(field, piece, maxClearLine);
            stopwatch1.stop();
            // LockedNeighborCandidate
            stopwatch2.start();
            Set<Neighbor> neighbors = candidate2.search(field, piece, maxClearLine);
            stopwatch2.stop();
            Set<Action> search2 = neighbors.stream().map(Neighbor::getPiece).map(this::createMinimalAction).map(action -> minoShifter.createTransformedAction(piece, action)).collect(Collectors.toSet());
            replacedertThat(search2).isEqualTo(search1);
        }
    }
    System.out.println(stopwatch1.toMessage(TimeUnit.NANOSECONDS));
    System.out.println(stopwatch2.toMessage(TimeUnit.NANOSECONDS));
}