Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VSN = 3.3.4
VSN = 3.3.5

### Special characters

Expand Down
3 changes: 1 addition & 2 deletions src/cl_dqueue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,11 @@ item_extract(Dets, Key) ->


item_insert(Dets, Item, Priority) ->
Key = now(),
Key = erlang:unique_integer([positive, monotonic]),
ok = dets:insert(Dets, {Key, Priority, Item}),
Key.


item_lookup(Dets, Key) ->
[{Key, _Priority, Item}] = dets:lookup(Dets, Key),
Item.

6 changes: 3 additions & 3 deletions src/cl_queue_srv.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
-export([code_change/3]).

%%% RECORDS
-record(st, {parent, queue, in = 0, out = 0, start = now()}).
-record(st, {parent, queue, in = 0, out = 0, start = erlang:timestamp()}).

%%%-----------------------------------------------------------------------------
%%% START/STOP EXPORTS
Expand Down Expand Up @@ -155,7 +155,7 @@ handle_call(count_in, _From, St) ->
handle_call(count_out, _From, St) ->
{reply, St#st.out, St};
handle_call(rps_avg, _From, St) ->
Secs = timer:now_diff(now(), St#st.start) / 1000000,
Secs = timer:now_diff(erlang:timestamp(), St#st.start) / 1000000,
{reply, round(St#st.out / Secs), St};
handle_call(rps, From, St) ->
_Ref = erlang:start_timer(1000, self(), {rps, From, St#st.out}),
Expand All @@ -165,7 +165,7 @@ handle_call(stop, _From, St) ->


handle_cast(count_reset, St) ->
{noreply, St#st{in = 0, out = 0, start = now()}}.
{noreply, St#st{in = 0, out = 0, start = erlang:timestamp()}}.


handle_info({timeout, _Ref, {rps, From, Out}}, St) ->
Expand Down
11 changes: 6 additions & 5 deletions src/cl_timer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
%%% UTILITY EXPORTS
%%%-----------------------------------------------------------------------------
tc(Fun) ->
Before = erlang:now(),
Before = erlang:monotonic_time(micro_seconds),
Val = (catch Fun()),
After = erlang:now(),
{timer:now_diff(After, Before), Val}.
After = erlang:monotonic_time(micro_seconds),
Diff = After - Before,
{Diff, Val}.


tc_avg(M, F, A, N) when N > 0 ->
Expand All @@ -55,7 +56,7 @@ tc_avg(M, F, A, N) when N > 0 ->


then(TimeLapse) ->
{MegaSecs, Secs, MicroSecs} = now(),
{MegaSecs, Secs, MicroSecs} = erlang:timestamp(),
TotalMicroSecs = MicroSecs + TimeLapse,
SecsIncr = TotalMicroSecs div 1000000,
MicroSecsRest = TotalMicroSecs - (SecsIncr * 1000000),
Expand All @@ -66,7 +67,7 @@ then(TimeLapse) ->


tstamp() ->
{A, B, C} = now(),
{A, B, C} = erlang:timestamp(),
(((A * 1000000) * 1000) + (B * 1000) + (C div 1000)).

%%%-----------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions test/cl_consumer_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ suite() ->
%%%-----------------------------------------------------------------------------
init_per_suite(Conf) ->
lists:foreach(fun(X) -> code:add_path(X) end, ct:get_config(paths, [])),
{A1, A2, A3} = now(),
{A1, A2, A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
dbg:tracer(),
dbg:p(all, [c, sos, sol]),
Expand Down Expand Up @@ -301,4 +301,3 @@ purge_stub(Stub) ->
send_junk(Pid) ->
{links, L} = process_info(Pid, links),
lists:foreach(fun(X) -> X ! junk end, [Pid | L]).

8 changes: 4 additions & 4 deletions test/cl_dqueue_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ suite() ->

init_per_suite(Config) ->
lists:foreach(fun(X) -> code:add_path(X) end, ct:get_config(paths)),
{A1, A2, A3} = now(),
{A1, A2, A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
start_dbg(),
File = ct:get_config(file),
Expand Down Expand Up @@ -228,7 +228,7 @@ disk_usage() ->
[{userdata, [{doc, "Tests that dqueue conforms with disk usage restrictions."}]}].

disk_usage(Config) ->
{A1,A2,A3} = now(),
{A1,A2,A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
Max = ?config(max_operations, Config),
{ok, Q1} = cl_dqueue:open(?config(file, Config)),
Expand Down Expand Up @@ -267,15 +267,15 @@ disk_usage(Config) ->
in(Q, 0) ->
Q;
in(Q, N) ->
in(cl_dqueue:in(now(), Q, random:uniform(10) - 1), N - 1).
in(cl_dqueue:in(erlang:timestamp(), Q, random:uniform(10) - 1), N - 1).


in_out(Q, 0) ->
Q;
in_out(Q1, Times) ->
case random:uniform(2) of
1 ->
Q2 = cl_dqueue:in(now(), Q1, random:uniform(10) - 1),
Q2 = cl_dqueue:in(erlang:timestamp(), Q1, random:uniform(10) - 1),
in_out(Q2, Times - 1);
2 ->
{_, Q2} = cl_dqueue:out(Q1),
Expand Down
2 changes: 1 addition & 1 deletion test/cl_pool_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ suite() ->
%%%-----------------------------------------------------------------------------
init_per_suite(Conf) ->
lists:foreach(fun(X) -> code:add_path(X) end, ct:get_config(paths, [])),
{A1, A2, A3} = now(),
{A1, A2, A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
dbg:tracer(),
dbg:p(all, [c, sos, sol]),
Expand Down
6 changes: 3 additions & 3 deletions test/cl_queue_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ suite() ->

init_per_suite(Config) ->
lists:foreach(fun(X) -> code:add_path(X) end, ct:get_config(paths)),
{A1, A2, A3} = now(),
{A1, A2, A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
start_dbg(),
File = ct:get_config(file),
Expand Down Expand Up @@ -227,15 +227,15 @@ performance(Config) ->
in(Q, 0) ->
Q;
in(Q, N) ->
in(cl_queue:in(now(), Q, random:uniform(10) - 1), N - 1).
in(cl_queue:in(erlang:timestamp(), Q, random:uniform(10) - 1), N - 1).


in_out(Q, 0) ->
Q;
in_out(Q1, Times) ->
case random:uniform(2) of
1 ->
Q2 = cl_queue:in(now(), Q1, random:uniform(10) - 1),
Q2 = cl_queue:in(erlang:timestamp(), Q1, random:uniform(10) - 1),
in_out(Q2, Times - 1);
2 ->
{_, Q2} = cl_queue:out(Q1),
Expand Down
4 changes: 2 additions & 2 deletions test/cl_queue_srv_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ suite() ->
%%%-----------------------------------------------------------------------------
init_per_suite(Conf) ->
lists:foreach(fun(X) -> code:add_path(X) end, ct:get_config(paths, [])),
{A1, A2, A3} = now(),
{A1, A2, A3} = erlang:timestamp(),
random:seed(A1, A2, A3),
dbg:tracer(),
dbg:p(all, [c, sos, sol]),
Expand Down Expand Up @@ -244,7 +244,7 @@ in_out(Pid, 0) ->
in_out(Pid, Times) ->
case random:uniform(2) of
1 ->
ok = cl_queue_srv:in(Pid, now(), random:uniform(10) - 1),
ok = cl_queue_srv:in(Pid, erlang:timestamp(), random:uniform(10) - 1),
in_out(Pid, Times - 1);
2 ->
_ = dqueue:out(Pid),
Expand Down