Skip to content

Instantly share code, notes, and snippets.

@toopay
Created January 2, 2015 07:43
Show Gist options
  • Save toopay/7ec64c0d49dca750aca5 to your computer and use it in GitHub Desktop.
Save toopay/7ec64c0d49dca750aca5 to your computer and use it in GitHub Desktop.
Useless worker
-module(worker).
-export([do_the_useless_job/0]).
do_the_useless_job() ->
TimeStart = unixtime(),
G = fun(X) -> timer:sleep(100), io:format("~p~n", [X]) end,
[spawn(fun() -> G(X) end) || X <- lists:seq(1,10)],
io:format("All done in ~p microseconds~n", [unixtime()-TimeStart]).
unixtime() ->
{X,Y,Z} = erlang:now(),
(X * 1000000 * 1000000) + (Y * 1000000) + Z.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment