Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
2198-Measure-lcg35_bytes.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2198-Measure-lcg35_bytes.patch of Package erlang
From 406d7b863131c0316f8b863375fa64f48bd27397 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen <raimo@erlang.org> Date: Sat, 2 Apr 2022 01:02:21 +0200 Subject: [PATCH 08/11] Measure lcg35_bytes --- lib/stdlib/test/rand_SUITE.erl | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/stdlib/test/rand_SUITE.erl b/lib/stdlib/test/rand_SUITE.erl index c6762c1626..53e6e30a09 100644 --- a/lib/stdlib/test/rand_SUITE.erl +++ b/lib/stdlib/test/rand_SUITE.erl @@ -1480,7 +1480,7 @@ do_measure(Iterations) -> %% ByteSize = 16, % At about 100 bytes crypto_bytes breaks even to exsss ct:pal("~nRNG ~w bytes performance~n",[ByteSize]), - _ = + [TMarkBytes16,OverheadBytes16|_] = measure_1( fun (Mod, _State) -> Generator = fun Mod:bytes_s/2, @@ -1495,6 +1495,15 @@ do_measure(Iterations) -> _ -> Algs end, Iterations), + _ = + measure_1( + fun (_Mod, _State) -> + fun (St0) -> + ?CHECK_BYTE_SIZE( + lcg35_bytes(ByteSize, St0), ByteSize, Bin, St1) + end + end, lcg35_bytes, Iterations, + TMarkBytes16, OverheadBytes16), %% ct:pal("~nRNG uniform float performance~n",[]), [TMarkUniformFloat,OverheadUniformFloat|_] = @@ -1680,6 +1689,9 @@ measure_init(Alg) -> lcg35_inline -> {_, S} = rand:seed_s(dummy), {rand, S bsr (58-35)}; + lcg35_bytes -> + {_, S} = rand:seed_s(dummy), + {rand, S bsr (58-35)}; splitmix64_inline -> {rand, erlang:unique_integer()}; lcg35_procdict -> @@ -1710,6 +1722,20 @@ bytes_s(N, undefined = St) -> %% crypto_bytes {crypto:strong_rand_bytes(N), St}. +lcg35_bytes(N, R0) -> + lcg35_bytes(N, R0, <<>>). +%% +lcg35_bytes(N, R0, Bin) when N < 4 -> + R1 = rand:lcg35(R0), + Bits = N bsl 3, + V = R1 bsr (35 - Bits), + {<<Bin/binary, V:Bits>>, R1}; +lcg35_bytes(N, R0, Bin) -> + R1 = rand:lcg35(R0), + V = R1 bsr (35 - 32), + lcg35_bytes(N - 4, R1, <<Bin/binary, V:32>>). + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% The jump sequence tests has two parts %% for those with the functional API (jump/1) -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor