aboutsummaryrefslogtreecommitdiff
path: root/src/tests/random.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/random.cpp')
-rw-r--r--src/tests/random.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/tests/random.cpp b/src/tests/random.cpp
index 3799803..e48c543 100644
--- a/src/tests/random.cpp
+++ b/src/tests/random.cpp
@@ -9,41 +9,41 @@ using namespace Bu;
9template<typename T> 9template<typename T>
10void coverage() 10void coverage()
11{ 11{
12 T rand; 12 T rand;
13 rand.seed( time( NULL ) ); 13 rand.seed( time( NULL ) );
14 14
15 uint32_t uBucket[78]; 15 uint32_t uBucket[78];
16 memset( uBucket, 0, sizeof(uint32_t)*78 ); 16 memset( uBucket, 0, sizeof(uint32_t)*78 );
17 17
18 for( int j = 0; j < 1000000; j++ ) 18 for( int j = 0; j < 1000000; j++ )
19 { 19 {
20 uBucket[(int)(((uint32_t)rand.rand())/(double)(0xfffffffful)*78+0.5)]++; 20 uBucket[(int)(((uint32_t)rand.rand())/(double)(0xfffffffful)*78+0.5)]++;
21 } 21 }
22 22
23 uint32_t uMax = 0; 23 uint32_t uMax = 0;
24 for( int j = 0; j < 78; j++ ) 24 for( int j = 0; j < 78; j++ )
25 { 25 {
26 if( uMax < uBucket[j] ) 26 if( uMax < uBucket[j] )
27 uMax = uBucket[j]; 27 uMax = uBucket[j];
28 } 28 }
29 29
30 for( int y = 20; y >= 1; y-- ) 30 for( int y = 20; y >= 1; y-- )
31 { 31 {
32 uint32_t iT = (uint32_t)((y/20.0)*uMax); 32 uint32_t iT = (uint32_t)((y/20.0)*uMax);
33 for( int x = 0; x < 78; x++ ) 33 for( int x = 0; x < 78; x++ )
34 { 34 {
35 sio << ((iT<=uBucket[x])?"#":" "); 35 sio << ((iT<=uBucket[x])?"#":" ");
36 } 36 }
37 sio << sio.nl; 37 sio << sio.nl;
38 } 38 }
39} 39}
40 40
41int main() 41int main()
42{ 42{
43 coverage<RandomBasic>(); 43 coverage<RandomBasic>();
44 coverage<RandomCmwc>(); 44 coverage<RandomCmwc>();
45 coverage<RandomSystem>(); 45 coverage<RandomSystem>();
46 46
47 return 0; 47 return 0;
48} 48}
49 49