September 2013
Intermediate to advanced
548 pages
12h 25m
English
At this point, you might be worried about performance. After all, if we’re creating hundreds or thousands of Erlang processes, we must be paying some kind of penalty. Let’s find out how much.
We’ll do a bunch of spawns, create loads of processes, and
time how long it takes. Here’s the program; note that here we
use spawn(Fun) and that the function being spawned does
not have to be exported from the module:
| processes.erl | |
| | -module(processes). |
| | |
| | -export([max/1]). |
| | |
| | %% max(N) |
| | |
| | %% Create N processes then destroy them |
| | %% See how much time this takes |
| | |
| | max(N) -> |
| | Max = erlang:system_info(process_limit), |
| | io:format("Maximum allowed processes:~p~n",[Max]), |
| | statistics(runtime), |
| | statistics(wall_clock), ... |
Read now
Unlock full access