-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuoy_profile.erl
More file actions
55 lines (42 loc) · 1.03 KB
/
Copy pathbuoy_profile.erl
File metadata and controls
55 lines (42 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-module(buoy_profile).
-export([
fprofx/0
]).
-define(N, 1000).
-define(P, 20).
%% public
-spec fprofx() -> ok.
fprofx() ->
Filenames = filelib:wildcard("_build/default/lib/*/ebin/*.beam"),
Rootnames = [filename:rootname(Filename, ".beam") ||
Filename <- Filenames],
lists:foreach(fun code:load_abs/1, Rootnames),
BuoyUrl = buoy_utils:parse_url(<<"http://127.0.0.1:8080/1">>),
fprofx:start(),
{ok, Tracer} = fprofx:profile(start),
fprofx:trace([start, {procs, new}, {tracer, Tracer}]),
buoy_app:start(),
buoy_pool:start(BuoyUrl),
Self = self(),
[spawn(fun () ->
[{ok, _} = buoy_get(BuoyUrl) || _ <- lists:seq(1, ?N)],
Self ! exit
end) || _ <- lists:seq(1, ?P)],
wait(),
fprofx:trace(stop),
fprofx:analyse([totals, {dest, ""}]),
fprofx:stop(),
buoy_app:stop(),
ok.
%% private
buoy_get(BuoyUrl) ->
{ok, _} = buoy:get(BuoyUrl).
wait() ->
wait(?P).
wait(0) ->
ok;
wait(X) ->
receive
exit ->
wait(X - 1)
end.