[erlang-questions] Erlang concurreny on Windows

William H Pyritz pyritz@REDACTED
Wed Apr 9 20:09:23 CEST 2008


Hello,

I hope you can help me understand some results from an Erlnag
concurrency test I recently performed. I am using a dual core Intel
T2500 CPU @ 2GHz with 1G RAM running Windows XP Pro.

erl -version:
	Erlang (ASYNC_THREADS) (BEAM) emulator version 5.5.5

I was watching the CPU monitor and noticed that one core was at nearly
100% and the other at ~80% for both of the following tests. I expected
to see a significant difference in the times (marked as OUTPUT below).

Is there something I am doing wrong that might explain the reults, or is
Windows doing some optimizations on the first test?

Thanks,

Bill Pyritz
-------------------------------------------------------------
test_concurrency1() ->
    statistics(runtime),
    statistics(wall_clock),
    for( 1, 100000000, fun(Index) -> Index * 10 end ),
    {_, Time1} = statistics(runtime),
    {_, Time2} = statistics(wall_clock),
    io:format("~p ~p ~n", [Time1, Time2]).
OUTPUT => 15781 15797

test_concurrency2() ->
    statistics(runtime),
    statistics(wall_clock),
    S = self(),
    spawn( fun() -> for( 1, 50000000, fun(Index) -> Index * 10 end ), S
! done end ),
    spawn( fun() -> for( 1, 50000000, fun(Index) -> Index * 10 end ), S
! done end ),
    for( 1, 2, fun(_) -> receive done -> done end end ),
    {_, Time3} = statistics(runtime),
    {_, Time4} = statistics(wall_clock),
    io:format("~p ~p ~n", [Time3, Time4]).
OUTPUT => 15531 15531






More information about the erlang-questions mailing list