Change app7 to use StopWatch
This commit is contained in:
parent
6079bb6957
commit
8197618f97
1 changed files with 9 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import core.thread;
|
import core.thread;
|
||||||
import std.perf;
|
import std.datetime;
|
||||||
|
|
||||||
// Yield count should be larger for a
|
// Yield count should be larger for a
|
||||||
// more accurate measurment, but this
|
// more accurate measurment, but this
|
||||||
|
@ -38,12 +38,12 @@ void fiber_test()
|
||||||
foreach( ref f; fib_array )
|
foreach( ref f; fib_array )
|
||||||
f = new Fiber( &fiber_func );
|
f = new Fiber( &fiber_func );
|
||||||
|
|
||||||
auto timer = new PerformanceCounter;
|
StopWatch sw;
|
||||||
|
|
||||||
uint i = yield_count;
|
uint i = yield_count;
|
||||||
|
|
||||||
// fibers are cooperative and need a driver loop
|
// fibers are cooperative and need a driver loop
|
||||||
timer.start();
|
sw.start();
|
||||||
bool done;
|
bool done;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -55,10 +55,10 @@ void fiber_test()
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
} while( !done );
|
} while( !done );
|
||||||
timer.stop();
|
sw.stop();
|
||||||
|
|
||||||
writeln( "Elapsed time for ", worker_count, " workers times ", yield_count, " yield() calls with fibers = ",
|
writeln( "Elapsed time for ", worker_count, " workers times ", yield_count, " yield() calls with fibers = ",
|
||||||
timer.milliseconds, "ms" );
|
sw.peek().msecs, "ms" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void thread_test()
|
void thread_test()
|
||||||
|
@ -68,14 +68,14 @@ void thread_test()
|
||||||
foreach( ref t; thread_array )
|
foreach( ref t; thread_array )
|
||||||
t = new Thread( &thread_func );
|
t = new Thread( &thread_func );
|
||||||
|
|
||||||
auto timer = new PerformanceCounter;
|
StopWatch sw;
|
||||||
timer.start();
|
sw.start();
|
||||||
foreach( t; thread_array )
|
foreach( t; thread_array )
|
||||||
t.start();
|
t.start();
|
||||||
thread_joinAll();
|
thread_joinAll();
|
||||||
timer.stop();
|
sw.stop();
|
||||||
writeln( "Elapsed time for ", worker_count, " workers times ", yield_count, " yield() calls with threads = ",
|
writeln( "Elapsed time for ", worker_count, " workers times ", yield_count, " yield() calls with threads = ",
|
||||||
timer.milliseconds, "ms" );
|
sw.peek().msecs, "ms" );
|
||||||
}
|
}
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue