All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jupiter.tools.stress.test.concurrency.strategy.ParallelStreamTestRunner Maven / Gradle / Ivy

The newest version!
package com.jupiter.tools.stress.test.concurrency.strategy;


import com.jupiter.tools.stress.test.concurrency.CallableVoid;
import com.jupiter.tools.stress.test.concurrency.testrunner.*;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * Created on 13.09.2018.
 * 

* TestRunner implementation based on the parallel stream * * @author Korovin Anatoliy */ public class ParallelStreamTestRunner implements TestRunner { @SuppressWarnings("Duplicates") @Override public TestRunnerResult run(CallableVoid testCase, TestRunnerSettings settings) { List errors = initEmptyErrorList(); long before = System.currentTimeMillis(); long limit = before + settings.getTimeout() .getTimeUnit().toMillis(settings.getTimeout().getDuration()); List results = IntStream.range(0, settings.getIterationCount()) .boxed() .parallel() .map(i -> { if (System.currentTimeMillis() > limit) { throw new RuntimeException("StressTestRunner Timeout Error"); } return i; }) .map(i -> executeOneIterationResult(testCase, errors)) .collect(Collectors.toList()); return new TestRunnerResult(errors, results); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy