Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
2968-Add-a-measure-1-point-for-range-10000.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2968-Add-a-measure-1-point-for-range-10000.patch of Package erlang
From 08f343bed4f75bf345b04b4c1fac7e1026a50ab3 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen <raimo@erlang.org> Date: Thu, 12 May 2022 08:53:34 +0200 Subject: [PATCH 8/8] Add a measure/1 point for range 10000 The mwc59_raw generator's low 16 bits can be used in truncated multiplication for this range, so measure the speed. Rename measure/1 tags _mas to _tm because truncated multiplication is a more generic name than multiply-and-shift. --- lib/stdlib/test/rand_SUITE.erl | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/stdlib/test/rand_SUITE.erl b/lib/stdlib/test/rand_SUITE.erl index 05dcd897c3..11722fd060 100644 --- a/lib/stdlib/test/rand_SUITE.erl +++ b/lib/stdlib/test/rand_SUITE.erl @@ -1172,7 +1172,25 @@ do_measure(Iterations) -> Range = 10000, fun (St0) -> St1 = rand:mwc59(St0), - %% Multiply-and-shift, slightly skewed + %% Truncated multiplication, slightly skewed + case + ((Range * (St1 band ((1 bsl 16)-1))) bsr 16) + + 1 + of + R when is_integer(R), 0 < R, R =< Range -> + St1 + end + end + end, + {mwc59,raw_tm}, Iterations, + TMarkUniformRange10000, OverheadUniformRange1000), + _ = + measure_1( + fun (_Mod, _State) -> + Range = 10000, + fun (St0) -> + St1 = rand:mwc59(St0), + %% Truncated multiplication, slightly skewed case ((Range * rand:mwc59_value32(St1)) bsr 32) + 1 @@ -1182,7 +1200,7 @@ do_measure(Iterations) -> end end end, - {mwc59,value32_mas}, Iterations, + {mwc59,value32_tm}, Iterations, TMarkUniformRange10000, OverheadUniformRange1000), _ = measure_1( @@ -1190,7 +1208,7 @@ do_measure(Iterations) -> Range = 10000, % 14 bits fun (St0) -> St1 = rand:mwc59(St0), - %% Multiply-and-shift, slightly skewed + %% Truncated multiplication, slightly skewed case ( (Range * (rand:mwc59_value(St1) bsr 14) ) @@ -1202,7 +1220,7 @@ do_measure(Iterations) -> end end end, - {mwc59,value_mas}, Iterations, + {mwc59,value_tm}, Iterations, TMarkUniformRange10000, OverheadUniformRange1000), _ = measure_1( @@ -1210,7 +1228,7 @@ do_measure(Iterations) -> Range = 10000, fun (St0) -> {V,St1} = rand:exsp_next(St0), - %% Multiply-and-shift, slightly skewed + %% Truncated multiplication, slightly skewed case ((Range * (V bsr 14)) bsr (58-14)) + 1 of @@ -1219,7 +1237,7 @@ do_measure(Iterations) -> end end end, - {exsp,mas}, Iterations, + {exsp,tm}, Iterations, TMarkUniformRange10000, OverheadUniformRange1000), _ = measure_1( -- 2.35.3
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