[Shootout-list] Process Creation - useless test output

Bengt Kleberg bengt.kleberg@ericsson.com
Mon, 04 Oct 2004 12:45:43 +0200


This is a multi-part message in MIME format.
--------------030607020900030101050509
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Isaac Gouy wrote:
> Unlike other benchmarks, the output from the new Process Creation test
> gives no indication if the test has been performed correctly. 
> 
> We might have created 5 processes or 50,000 processes - these programs
> are just echoing the input parameter, without any reference to what the
> programs are doing.

this is correct. it is largely due to the fact that we are masuring the 
speed of a side effect. ie, we are not interested in the value of 
creating processes, but the cost.

we could change the code to return how many process there are left to 
create, after the test has been run. And then display the difference 
between what we wanted to create and how many that are left to create. 
ok? (sample in erlang attached below)


bengt


--------------030607020900030101050509
Content-Type: text/plain;
 name="procinst.erl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="procinst.erl"

-module(procinst).
-export([main/0, main/1]).

main() -> main(['1']).
main([Arg]) ->
	Number_of_Processes = atom_to_integer( Arg ),
	Processes_Not_Created = procinst( Number_of_Processes ),
	io:fwrite( "~w\n", [Number_of_Processes - Processes_Left] ),
	erlang:halt().

atom_to_integer( Atom ) ->
	erlang:list_to_integer(erlang:atom_to_list(Atom)).

procinst( 0 ) -> 0;
procinst( N ) ->
	erlang:spawn( fun() -> loop() end ),
	procinst( N-1 ).

loop( ) ->
	receive
	_Something ->
		loop( )
	end.

--------------030607020900030101050509--