-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathmarina_profile.erl
More file actions
87 lines (73 loc) · 2.61 KB
/
Copy pathmarina_profile.erl
File metadata and controls
87 lines (73 loc) · 2.61 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
-module(marina_profile).
-include("test.hrl").
-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),
marina_app:start(),
setup(),
marina_app:stop(),
fprofx:start(),
{ok, Tracer} = fprofx:profile(start),
fprofx:trace([start, {procs, new}, {tracer, Tracer}]),
Self = self(),
Query = <<"SELECT * FROM test.users WHERE key = ?;">>,
Uid = <<153, 73, 45, 254, 217, 74, 17, 228, 175, 57, 88,
244, 65, 16, 117, 125>>,
Opts = [{skip_metadata, true}],
marina_app:start(),
[spawn(fun () ->
[{ok, _} = marina:reusable_query(Query, [Uid], ?CONSISTENCY_LOCAL_ONE,
Opts, ?TIMEOUT) || _ <- lists:seq(1, ?N)],
Self ! exit
end) || _ <- lists:seq(1, ?P)],
wait(),
fprofx:trace(stop),
fprofx:analyse([totals, {dest, ""}]),
fprofx:stop(),
marina_app:stop(),
ok.
%% private
setup() ->
[marina:query(Query, [], ?CONSISTENCY_LOCAL_ONE, [], ?TIMEOUT) || Query <- [
<<"DROP KEYSPACE test;">>,
<<"CREATE KEYSPACE test WITH REPLICATION =
{'class':'SimpleStrategy', 'replication_factor':1};">>,
<<"CREATE TABLE test.users (key uuid, column1 text,
column2 text, value blob, PRIMARY KEY (key, column1, column2));">>,
<<"INSERT INTO test.users (key, column1, column2, value)
values (99492dfe-d94a-11e4-af39-58f44110757d, 'test', 'test2',
intAsBlob(0))">>,
<<"INSERT INTO test.users (key, column1, column2, value)
values (99492dfe-d94a-11e4-af39-58f44110757d, 'test2', 'test3',
intAsBlob(0))">>,
<<"INSERT INTO test.users (key, column1, column2, value)
values (99492dfe-d94a-11e4-af39-58f44110757d, 'test3', 'test4',
intAsBlob(0))">>,
<<"INSERT INTO test.users (key, column1, column2, value)
values (99492dfe-d94a-11e4-af39-58f44110757d, 'test4', 'test5',
intAsBlob(0))">>,
<<"INSERT INTO test.users (key, column1, column2, value)
values (99492dfe-d94a-11e4-af39-58f44110757d, 'test5', 'test6',
intAsBlob(0))">>,
<<"INSERT INTO test.users (key, column1, column2, value)
values (99492dfe-d94a-11e4-af39-58f44110757d, 'test6', 'test7',
intAsBlob(0))">>
]].
wait() ->
wait(?P).
wait(0) ->
ok;
wait(X) ->
receive
exit ->
wait(X - 1)
end.