This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
src/System.Runtime.Extensions/tests/Performance Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -49,5 +49,34 @@ public void Next_int_int()
4949 rand . Next ( 100 , 10000 ) ; rand . Next ( 100 , 10000 ) ; rand . Next ( 100 , 10000 ) ;
5050 }
5151 }
52+
53+ [ Benchmark ]
54+ public void NextBytes ( )
55+ {
56+ Random rand = new Random ( 123456 ) ;
57+ byte [ ] b1 = new byte [ 1000 ] ;
58+ foreach ( var iteration in Benchmark . Iterations )
59+ using ( iteration . StartMeasurement ( ) )
60+ for ( int i = 0 ; i < 10000 ; i ++ )
61+ {
62+ rand . NextBytes ( b1 ) ; rand . NextBytes ( b1 ) ; rand . NextBytes ( b1 ) ;
63+ rand . NextBytes ( b1 ) ; rand . NextBytes ( b1 ) ; rand . NextBytes ( b1 ) ;
64+ rand . NextBytes ( b1 ) ; rand . NextBytes ( b1 ) ; rand . NextBytes ( b1 ) ;
65+ }
66+ }
67+
68+ [ Benchmark ]
69+ public void NextDouble ( )
70+ {
71+ Random rand = new Random ( 123456 ) ;
72+ foreach ( var iteration in Benchmark . Iterations )
73+ using ( iteration . StartMeasurement ( ) )
74+ for ( int i = 0 ; i < 40000 ; i ++ )
75+ {
76+ rand . NextDouble ( ) ; rand . NextDouble ( ) ; rand . NextDouble ( ) ;
77+ rand . NextDouble ( ) ; rand . NextDouble ( ) ; rand . NextDouble ( ) ;
78+ rand . NextDouble ( ) ; rand . NextDouble ( ) ; rand . NextDouble ( ) ;
79+ }
80+ }
5281 }
5382}
You can’t perform that action at this time.
0 commit comments