Skip to content

Instantly share code, notes, and snippets.

@soranoba
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soranoba/6c4bf489714618366a1c to your computer and use it in GitHub Desktop.
Save soranoba/6c4bf489714618366a1c to your computer and use it in GitHub Desktop.
mustache bench.erl
-module(bench).
-compile(export_all).
run() ->
lists:sum([begin {T, _} = timer:tc(?MODULE, render, []), T end || _ <- lists:seq(1, 1000)]).
render() ->
Ctx = dict:from_list([{name, "Chris"}, {value, 10000}, {taxed_value, 10000 - (10000 * 0.4)}, {in_ca, true}]),
mustache:render("Hello {{name}} You have just won {{value}} dollars! {{#in_ca}} Well, {{taxed_value}} dollars, after taxes. {{/in_ca}}", Ctx).
-module(bench).
-compile(export_all).
run() ->
lists:sum([begin {T, _} = timer:tc(?MODULE, render, []), T end || _ <- lists:seq(1, 1000)]).
render() ->
Ctx = #{"name" => "Chris", "value" => 10000, "taxed_value" => 10000 - (10000 * 0.4), "in_ca" => true},
mustache:render(<<"Hello {{name}} You have just won {{value}} dollars! {{#in_ca}} Well, {{taxed_value}} dollars, after taxes. {{/in_ca}}">>, Ctx).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment