Skip to content

runidle/runidle-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

runidle-testing

Asynchronous unit test and benchmark library

For asynchronous programming, it's not easy to do the unit test. Particularly, it's hard to do the benchmark for asynchronous program.

Runidle-Testing is designed to help for the unit tests and benchmark on asynchronous programming.

Unit Test on RxJava programming

public class RxJavaUnit extends BaseUnitSpec  {
    @Test
    public void testRxJava() {
        Blocker blocker = new Blocker();
        Observable.just(1)
             .map(integer -> 1000)
             .observeOn(Schedulers.computation())
             .subscribe(integer -> {
                 assertEquals(integer.intValue(), 1000);
                 blocker.end();
             });
        blocker.awaitEnd();
    }
}

blocker: need to use blocker object to control the test workflow of asynchronous program

Benchmark on RxJava Programming

Benchmark.benchmark()
         .threads(1)        
         .concurrency(20000)
         .iterations(500)
         .rounds(10)
         .warmupConcurrency(10000)
         .warmupIterations(1000)
         .warmupRounds(1)
         .reportIntervalSeconds(3)
         .benchmarkTask((index, runnerContext) -> {
              Observable.just(index)
                        .subscribe(integer -> {
                                runnerContext.done(index);
                        }, throwable -> {
                                runnerContext.done(index);
                        });
         }).start();

threads: how many threads to start the benchmark.For asynchronous program, maybe need more threads to start iterations
concurrency: how many actors on asynchronous benchmark. For asynchronous program, the number of actors decides the concurrency, which is not decided by the threads.
iterations: how many iterations for each actors. This is not the total iterations. TotalIterations = concurrency*iterations Don't make the totalIteration too large. rounds: how many benchmark rounds
warmupConcurrency: how many actors for warmup.
warmupIterations: how many iterations for warmup.
warmupRounds: how many rounds for warmup.
reportIntervalSeconds: benchmark report interval. The default value is 2 seconds. In some case, the value should larger.

About

Asynchronous unit test and benchmark library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages