]>
git.proxmox.com Git - mirror_ovs.git/blob - tests/test-random.c
2 * Copyright (c) 2008, 2009, 2010 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
27 enum { N_ROUNDS
= 10000 };
28 unsigned long long int total
;
36 memset(hist2
, 0, sizeof hist2
);
37 memset(hist16
, 0, sizeof hist16
);
38 for (i
= 0; i
< N_ROUNDS
; i
++) {
46 for (j
= 0; j
< 32; j
++) {
52 for (j
= 0; j
< 8; j
++) {
53 hist16
[j
][(x
>> (j
* 4)) & 15]++;
57 printf("average=%08llx\n", total
/ N_ROUNDS
);
59 printf("\nbit 0 1\n");
60 for (i
= 0; i
< 32; i
++) {
61 printf("%3d %5d %5d\n", i
, N_ROUNDS
- hist2
[i
], hist2
[i
]);
63 printf("(expected values are %d)\n", N_ROUNDS
/ 2);
65 printf("\nnibble 0 1 2 3 4 5 6 7 8 9 10 11 12 "
67 for (i
= 0; i
< 8; i
++) {
71 for (j
= 0; j
< 16; j
++) {
72 printf(" %3d", hist16
[i
][j
]);
76 printf("(expected values are %d)\n", N_ROUNDS
/ 16);