aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/examples/bench/bench.hrl
blob: 7b0e0c12807583cafd19480c55ec0c9d9bdea8f8 (plain) (blame)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
%%
%% %CopyrightBegin%
%% 
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
%% 
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%% 
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%% 
%% %CopyrightEnd%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% File    : bench.hrl
%%% Author  : Hakan Mattsson <[email protected]>
%%% Purpose : Define various database records
%%% Created : 21 Jun 2001 by Hakan Mattsson <[email protected]>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-record(config,
        {
          generator_profile         = random,
          generator_warmup          = timer:seconds(2),
          generator_duration        = timer:seconds(15),
          generator_cooldown        = timer:seconds(2),
          generator_nodes           = [node() | nodes()],
          statistics_detail         = debug,
          n_generators_per_node     = 1,
          write_lock_type           = sticky_write,
          table_nodes               = [node() | nodes()],
          storage_type              = ram_copies,
          n_subscribers             = 25000,
          n_groups                  = 5,
          n_servers                 = 1,
          n_replicas                = 1,
          n_fragments               = 100,
          use_binary_subscriber_key = false,
	  always_try_nearest_node   = false,
          cookie                    = 'bench'
         }).

-record(subscriber,
        {
          subscriber_number, % string (10 chars)
          subscriber_name,   % string (32 chars)
          group_id,          % integer (uint32)
          location,          % integer (uint32)
          active_sessions,   % array of 32 booleans (32 bits)
          changed_by,        % string (25 chars)
          changed_time,      % string (25 chars)
          suffix
         }). 
 
-record(group, 
        {
          group_id,          % integer (uint32)
          group_name,        % string (32 chars)
          allow_read,        % array of 32 booleans (32 bits)
          allow_insert,      % array of 32 booleans (32 bits)
          allow_delete       % array of 32 booleans (32 bits)
         }).

-record(server,
        {
          server_key,        % {ServerId, SubscriberNumberSuffix}
          server_name,       % string (32 chars)
          no_of_read,        % integer (uint32)
          no_of_insert,      % integer (uint32)
          no_of_delete,      % integer (uint32)
          suffix
         }).

-record(session,
        {
          session_key,       % {SubscriberNumber, ServerId}
          session_details,   % string (4000 chars)
          suffix
        }).

-define(d(Format, Args),
        io:format("~s" ++ Format, [string:left(lists:flatten(io_lib:format("~p(~p):", [?MODULE, ?LINE])), 30, $ ) | Args])).

-define(e(Format, Args),
        begin 
            ok = error_logger:format("~p(~p): " ++ Format, [?MODULE, ?LINE | Args]),
            timer:sleep(1000)
        end).

-define(ERROR(M, F, A, R),
        ?e("~w:~w~p\n\t ->~p\n", [M, F, A, R])).

-define(APPLY(M, F, A),
        fun() ->
                case catch apply(M, F, A) of
                    ok -> {ok, ok};
                    {atomic, R} -> {ok, R};
                    {ok, R} -> {ok, R};
                    {aborted, R} -> ?ERROR(M, F, A, R);
                    {error, R} ->  ?ERROR(M, F, A, R);
                    R -> ?ERROR(M, F, A, R)
                end
        end()).