I'm currently writing a small framework for demand-driven workflows. The API is now stable and I am working on improving tests. It's easy to show that computations are correct (which is a good start), however, the main interest of the framework is to launch subtasks in parallel (when needed and possible).
Is there a way to test automatically that two different pieces of code do run in a parallel/concurrent fashion ? I prefer not relying on execution time (speed-up) measurments.
The framework is written in scala, and relies a lot on Akka Futures.
EDIT:
Here is an example:
val foo = step {
//... defines an arbitrary task
}
// Runs 5 times the code inside step foo
val foos = repeat( 5 )( foo )
I would like to be sure that the code inside foo is executed 5 times in parallel.
I don't see a way to do this without changing tasks (i.e. when you need to test that two specific tasks run in parallel). But if you can change the tasks, just add an actor to the system. Make every task send messages to this actor when starting or ending work. If the actor receives two Starting messages in a row, the tasks should be running in parallel (or at least in different threads).
This test does not make any sense to me. On a computer with less than 5 cores you cannot get a parallelism of 5. It seems like you are testing Akka, which we are already doing, so just relax and test the dispatcher settings to verify that when it will run it will have the desired effect.
Hope that helps,
Cheers, √
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With