/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this Erlang HiPE program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
250,000Failed  997   

Read the ↓ make, command line, and program output logs to see how this program was run.

Read k-nucleotide benchmark to see what this program should do.

 notes

Erlang R16B (erts-5.10.1) [source] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

 k-nucleotide Erlang HiPE #2 program source code

% The Computer Language Benchmarks Game
% http://benchmarksgame.alioth.debian.org/
%%
%% k-nucleotide - using binaries and process dictionaries
%% Contributed by Erik Søe Sørensen
%%

-module(knucleotide_pdict).

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

-define(WORKER_LENGTHS, [1,2,3,4,6,12,18]).
-define(WORKER_QUERIES,
		  [all_by_frequency,
		   all_by_frequency,
		   {find_frequency, <<"GGT">>},
		   {find_frequency, <<"GGTA">>},
		   {find_frequency, <<"GGTATT">>},
		   {find_frequency, <<"GGTATTTTAATT">>},
		   {find_frequency, <<"GGTATTTTAATTTATAGT">>}]).

find_seq() ->
    case io:get_line('') of
	<<">", _/binary>> ->
	    ok;         % Found
	eof ->
	    exit(eof);
	_ ->
	    find_seq()  % Keep searching
    end.

process_seq(Dests) ->
    case io:get_line('') of
	<<">", _/binary>> ->
	    done;
	eof ->
	    lists:foreach(fun(Dest)->Dest ! eof end, Dests),
	    ok;
	Line when is_binary(Line) ->
	    Data = normalize_line(Line),
	    lists:foreach(fun(Dest)->Dest ! Data end, Dests),
	    process_seq(Dests)
    end.


normalize_line(Bin) ->
    list_to_binary([to_upper(C) || C<-binary_to_list(Bin), C =/= $\n]).

to_upper(Char) when $a =< Char, Char =< $z -> Char - $a + $A;
to_upper(Char)                             -> Char.

spawn_worker(Len) ->
    spawn(fun()->worker_read(Len, 0, <<>>) end).

worker_read(Len, Total,Buf) when is_integer(Len),
				      is_integer(Total),
				is_binary(Buf),
				byte_size(Buf) < Len ->
    receive
	Data when is_binary(Data) ->
	    worker_read(Len, Total, <<Buf/binary, Data/binary>>);
	eof ->
	    worker_done(Total)
    end;
worker_read(Len, Total, Buf) when is_integer(Len),
                                is_integer(Total),
				is_binary(Buf),
				byte_size(Buf) >= Len ->
    <<Key:Len/binary, _/binary>> = Buf,
    Before = case get(Key) of
		 undefined -> 0;
		 X when is_integer(X) -> X
	     end,
    put(Key, Before + 1),
    <<_, Rest/binary>> = Buf,
    worker_read(Len, Total+1, Rest).

worker_done(Total) ->
    receive
	{all_by_frequency, Pid, Ref} ->
	    Answer = lists:keysort(2, get()),
	    TxtAnswer = lists:foldl(fun({Key,Freq},Acc) ->
					    [Key, $\ ,
					     io_lib:format("~.3f", [Freq*100/Total]),
					     $\n | Acc]
				    end, "\n", Answer),
	    Pid ! {Ref,TxtAnswer};
	{{find_frequency, Key}, Pid,Ref} ->
	    Freq = case get(Key) of
		       undefined -> 0;
		       X -> X
		   end,
	    TxtAnswer = [integer_to_list(Freq), $\t, Key, $\n],
	    Pid ! {Ref,TxtAnswer};
	stop ->
	    exit(normal)
    end,
    done.

body() ->
    %% Start workers in background:
    Pids = lists:map(fun spawn_worker/1, ?WORKER_LENGTHS),

    io:setopts(standard_io, [binary]),

    %% Skip to third sequence:
    find_seq(),
    find_seq(),
    find_seq(),
    process_seq(Pids),

    %% Request answers:
    Refs =
	lists:zipwith(fun (Pid,Query) ->
			      Ref = make_ref(),
			      Pid ! {Query, self(), Ref},
			      Ref
		      end,
		      Pids, ?WORKER_QUERIES),

    %% Receive and print answers:
    lists:foreach(fun(Ref) ->
			  receive {Ref, Answer} ->
				  io:put_chars(Answer)
			  end
		  end, Refs),
    ok.

main(_Args) ->
    body(),
    halt(0).

 make, command-line, and program output logs

Tue, 05 Mar 2013 18:22:01 GMT

MAKE:
mv knucleotide.hipe-2.hipe knucleotide.erl
/usr/local/src/otp_src_R16B/bin/erlc +native +"{hipe, [o3]}"  knucleotide.erl
/home/dunham/benchmarksgame_quadcore/knucleotide/tmp/knucleotide.beam: Module name 'knucleotide_pdict' does not match file name 'knucleotide'
make: [knucleotide.hipe-2.hipe_run] Error 1 (ignored)
0.90s to complete and log all make actions

COMMAND LINE:
/usr/local/src/otp_src_R16B/bin/erl -smp enable -noshell -run  knucleotide main 0 < knucleotide-input250000.txt

PROGRAM FAILED 


PROGRAM OUTPUT:
{"init terminating in do_boot",{undef,[{knucleotide,main,[["0"]],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}


Crash dump was written to: erl_crash.dump
init terminating in do_boot ()

Revised BSD license

  Home   Conclusions   License   Play