#!/usr/local/bin/rune -x # # Test overhead of non-threaded, threaded, and threaded+detached procedures. import "sys"; import ; alias stdio.File *stdout = stdio.stdout; int main(int ac, char **av) { int i; switch(ac) { case 1: # Normal call # for (i = 0; i < 1000000; ++i) test1(); break; case 2: # This makes a threaded call which does not detach # for (i = 0; i < 1000000; ++i) test2(); break; case 3: # Initial thread allocation overhead is high, force a # thread switch so the detached thread is able to run # and return before we create the next one so the thread # can be reused. We aren't testing uncached thead allocation # here. # for (i = 0; i < 1000000; ++i) { test3(); } break; } stdio.stdout->show("finished loops"); } void test1() { } thread void test2() { } thread void test3() { result; }