File 0001-replace-erlang-now-0-to-os-timestamp-0.patch of Package redo
From 5f3c1f6a950eaf136653ca643fc4836792f90dc5 Mon Sep 17 00:00:00 2001
From: Led <ledest@gmail.com>
Date: Sun, 25 Jun 2017 00:34:30 +0300
Subject: [PATCH 1/3] replace erlang:now/0 to os:timestamp/0
---
src/bench.erl | 8 ++++----
src/redo_concurrency_test.erl | 2 +-
test/redo_block_tests.erl | 8 ++++----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/bench.erl b/src/bench.erl
index e274c9d..6196130 100644
--- a/src/bench.erl
+++ b/src/bench.erl
@@ -3,19 +3,19 @@
sync(Num) ->
Redo = setup(),
- A = now(),
+ A = os:timestamp(),
ok = loop(Redo, Num),
- B = now(),
+ B = os:timestamp(),
print(Num,A,B),
ok.
async(Num, Concurrency) ->
Redo = setup(),
Self = self(),
- A = now(),
+ A = os:timestamp(),
Pids = [spawn_link(fun() -> loop(Redo, Num div Concurrency), Self ! {self(), done} end) || _ <- lists:seq(1, Concurrency)],
[receive {Pid, done} -> ok end || Pid <- Pids],
- B = now(),
+ B = os:timestamp(),
print(Num,A,B),
ok.
diff --git a/src/redo_concurrency_test.erl b/src/redo_concurrency_test.erl
index b0a6b0c..eaa819a 100644
--- a/src/redo_concurrency_test.erl
+++ b/src/redo_concurrency_test.erl
@@ -49,7 +49,7 @@ worker(Parent, N, 0) ->
Parent ! {self(), N, done};
worker(Parent, N, NumOps) ->
- random:seed(now()),
+ random:seed(os:timestamp()),
StrN = integer_to_list(N),
StrOp = integer_to_list(NumOps),
case random:uniform(100) of
diff --git a/test/redo_block_tests.erl b/test/redo_block_tests.erl
index 5b80348..302c845 100644
--- a/test/redo_block_tests.erl
+++ b/test/redo_block_tests.erl
@@ -50,7 +50,7 @@ seq_test_() ->
fun start/0,
fun stop/1,
fun(Pid) ->
- Key = lists:flatten(io_lib:format("~p-~p", [make_ref(),now()])),
+ Key = lists:flatten(io_lib:format("~p-~p", [make_ref(), os:timestamp()])),
Cmds = [redo_block:cmd(Pid, ["EXISTS", Key]),
redo_block:cmd(Pid, ["SET", Key, "1"]),
redo_block:cmd(Pid, ["GET", Key]),
@@ -71,7 +71,7 @@ parallel_test_() ->
fun(Pid) ->
Parent = self(),
Keygen = fun() ->
- iolist_to_binary(io_lib:format("~p-~p", [make_ref(),now()]))
+ iolist_to_binary(io_lib:format("~p-~p", [make_ref(), os:timestamp()]))
end,
%% Takes a unique key, inserts it, then reads it. With hundreds of concurrent
%% processes, if redo_block doesn't behave well, the val read might be different
@@ -97,7 +97,7 @@ timeout_test_() ->
fun start/0,
fun stop/1,
fun(Pid) ->
- Key = lists:flatten(io_lib:format("~p-~p", [make_ref(),now()])),
+ Key = lists:flatten(io_lib:format("~p-~p", [make_ref(), os:timestamp()])),
Cmds = [redo_block:cmd(Pid, ["EXISTS", Key]),
redo_block:cmd(Pid, ["SET", Key, "1"]),
redo_block:cmd(Pid, ["GET", Key], 0),
@@ -119,7 +119,7 @@ parallel_timeout_test_() ->
fun(Pid) ->
Parent = self(),
Keygen = fun() ->
- iolist_to_binary(io_lib:format("~p-~p", [make_ref(),now()]))
+ iolist_to_binary(io_lib:format("~p-~p", [make_ref(), os:timestamp()]))
end,
%% Takes a unique key, inserts it, then reads it. With hundreds of concurrent
%% processes, if redo_block doesn't behave well, the val read might be different
--
2.13.1