Same thing with unit_threaded on Phobos, 3x faster even without repeating the modules (0.1s vs 0.3s). Since the example is shorter than the other one, I'll post it here in case anyone else wants to try:

import unit_threaded.runner;

int main(string[] args) {
    return args.runTests!(
        "ustd.array",
        "ustd.ascii",
        "ustd.base64",
        "ustd.bigint",
        "ustd.bitmanip",
        "ustd.concurrency",
        "ustd.container",
        "ustd.cstream",
        );
}


On Saturday, 3 May 2014 at 21:42:13 UTC, Atila Neves wrote:
gdc gave _very_ different results. I had to use different modules because at some point tests started failing, but with gdc the threaded version runs ~3x faster.

On my own unit-threaded benchmarks, running the UTs for Cerealed over and over again was only slightly slower with threads than without. With dmd the threaded version was nearly 3x slower.

Atila

On Saturday, 3 May 2014 at 21:14:29 UTC, Atila Neves wrote:
  if(single) {
      foreach(test; tests) {
          test();
      }
  } else {
      foreach(test; tests.parallel) {

Try different batch size:
test.parallel(1), test.parallel(2) etc.

So as to not have thread creation be disproportionately represented, I repeated the module list over and over again, making the number of tests run equal to 9990. This takes 5s on my machine to run in on thread and 12s in multiple. Here are the things I tried:

1. Created my own TaskPool so I could decide how many threads to use 2. Changed the batch size in parallel from 1 to 10 to 100 to 1000 3. Explicitly spawn two threads and tell each to do a foreach on half of the tests


None of them made it go any faster. I had similar results using unit-threaded on my own projects. This is weird.

Atila

Reply via email to