• Erlang
  • 15 lines
  • 17 views
  • Pasted by anonymous on June 1, 2012
-module(foo).
-compile(export_all).

bench() ->
  Res1 = timer:tc(fun() -> times(1000, fun() -> [$1, $2, $3 | "456"] end) end),
  io:format("~p~n", [Res1]),
  Res2 = timer:tc(fun() -> times(1000, fun() -> "123" ++ "456" end) end),
  io:format("~p~n", [Res2]).

times(0, _Fun) ->
  [];

times(I, Fun) ->
  Fun(),
  times(I - 1, Fun).

Did you know? CLOSE

  • There are keyboard shortcuts!
    • When Creating A Paste
      • ALT+P Toggle Private
      • CTRL+Enter Create Paste
      • ALT+W Toggle word wrap
    • When Viewing A Paste
      • ALT+G Go to a line
      • ALT+CTRL+E Edit the paste
      • ALT+R Show the raw code
  • There are URL options!
    • When Creating A Paste
      • ?lang=Javascript to default to javascript
    • When Viewing A Paste
      • #L-N Jump to line number N
?