Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.

Benchmarking Using Browser-Based Animation
  • http://github.com/duomark/dk_yaws
  • http://github.com/duomark/bubba
Goal: Benchmark erlang constructs
BUBBA Application Elements
Erlang App Yaws Server Benchmark Browser HTML Form Data Viz

User

User d3.js Yaws Erlang index.yaws HTML form d3 submit get json benchmark results to json show chart
Embedding YAWS
dk_yaws/src/dk_yaws.app.src
  1. {application, dk_yaws,
  2. [
  3. {id, "DK-yaws"},
  4. {vsn, "0.1.1"},
  5. {description, "DuoMark embedded yaws webserver"},
  6. {modules, []},
  7. {registered, [dk_yaws_app, dk_yaws_sup, dk_yaws_server]},
  8. {applications, [kernel, stdlib, sasl, gs, appmon]},
  9. {included_applications, [crypto, ssl, inets, yaws]},
  10. {mod, {dk_yaws_app, []}},
  11. {env, []}
  12. ]}.
Embedding YAWS
dk_yaws/src/dk_yaws_server.erl
  1. run() ->
  2. GconfList = [{id, ?APP_ID}],
  3. SconfList = get_params(?PARAM_LIST),
  4. Docroot = proplists:get_value(?APP_PARAM_DOCROOT, SconfList),
  5. {ok, SCList, GC, ChildSpecs} =
  6. yaws_api:embedded_start_conf(Docroot, SconfList, GconfList, ?APP_ID),
  7. [supervisor:start_child(dk_yaws_sup, Ch) || Ch <- ChildSpecs],
  8. yaws_api:setconf(GC, SCList),
  9. {ok, self()}.
Embedding YAWS
dk_yaws/rel/files/vm.args
  1. %% vsn parameters
  2. {dk_yaws_vsn, "0.1.1"}.
  3. %% vm.args parameters
  4. {node_cookie, "dk_yaws"}.
  5. {node_name, "dk_yaws@127.0.0.1"}.
  6. %% app.config parameters
  7. {default_port, "8000"}.
  8. {default_ip, "\"0.0.0.0\""}.
  9. {default_docroot, "\"lib/dk_yaws-{{dk_yaws_vsn}}/priv/\""}.
Embedding YAWS
d3 Introduction
Browser to erlang interface
bubba/bubba/priv/index.yaws
  1. < form name="benchmark_request" method="get" >
  2. < select >
  3. < option value="data_access" default> Data Access < /option >
  4. ...
  5. < /select >
  6. < input type="button" value="Run Benchmark" onclick="d3_submit()" />

  7. < /form >
  8. function make_url() {
  9. var url = [
  10. window.location, '/bench_results.yaws?',
  11. 'bench_type=', form.bench_type.value,
  12. '&bench=', form.bench.value,
  13. ...
  14. ].join('');
  15. return url;
  16. }
Browser to erlang interface
bubba/bubba/priv/index.yaws
  1. function d3_submit() {
  2. d3.json(make_url(), function(json) {
  3. var len = (json && json.results) ? json.results.length : 0;
  4. var data = [];
  5. for (i=0; i < len-1; i++) {
  6. data.push([i, json.results[i].loop_time.ms]);
  7. }
  8. var chart = bubba_time_series_chart()
  9. .x(function(d) {return d[0]})
  10. .y(function(d) {return d[1]});
  11. d3.select(".graph_area")
  12. .datum(data).call(chart);
  13. });
  14. }
Browser to erlang interface
  • Form layout
  • JSON connection to erlang
  • YAWS app executes server code
bubba/bubba/priv/index.yaws
  1. < erl >
  2. out(A) ->
  3. Query = yaws_api:parse_query(A),
  4. [BenchType, Bench, DataSize, ExecCount, NumTimes]
  5. = [proplists:get_value(Attr, Query)
  6. || Attr <- ["bench_type", "bench", "datasize",
  7. "num_execs", "test_times"]],
  8. bench(list_to_atom(BenchType), list_to_atom(Bench),
  9. list_to_integer(DataSize), list_to_integer(ExecCount),
  10. list_to_integer(NumTimes)).
  11. bench(data_access, FunType, DataSize, ExecCount, NumTimes) ->
  12. Proplist = bubba_server:access(FunType, DataSize, ExecCount, NumTimes),
  13. {content, "application/json", result_to_json(Proplist)};
  14. ...
  15. < /erl >
Browser to erlang interface
  • Form layout
  • JSON connection to erlang
  • YAWS app executes server code

Use a spacebar or arrow keys to navigate