23 #include <ndb_global.h>
38 unsigned short int x[3];
39 unsigned short int a[3];
67 static void localRandom48Init(
long int seedval,
DRand48Data *buffer)
70 if (
sizeof (
long int) > 4)
71 seedval &= 0xffffffffl;
73 #if USHRT_MAX == 0xffffU
74 buffer->x[2] = (
unsigned short)(seedval >> 16);
75 buffer->x[1] = (
unsigned short)(seedval & 0xffffl);
76 buffer->x[0] = 0x330e;
79 buffer->a[1] = 0xdeec;
80 buffer->a[0] = 0xe66d;
82 buffer->x[2] = seedval;
83 buffer->x[1] = 0x330e0000UL;
86 buffer->a[2] = 0x5deecUL;
87 buffer->a[1] = 0xe66d0000UL;
95 static void localRandom48(
DRand48Data *buffer,
long int *result)
105 #if (USHRT_MAX == 0xffffU)
107 buffer->a[1] = 0xdeec;
108 buffer->a[0] = 0xe66d;
110 buffer->a[2] = 0x5deecUL;
111 buffer->a[1] = 0xe66d0000UL;
122 if (
sizeof (
unsigned short int) == 2) {
123 X = (Uint64)buffer->x[2] << 32 |
124 (Uint64)buffer->x[1] << 16 |
126 a = ((Uint64)buffer->a[2] << 32 |
127 (Uint64)buffer->a[1] << 16 |
130 loc_result = X * a + buffer->c;
132 buffer->x[0] = (
unsigned short)(loc_result & 0xffff);
133 buffer->x[1] = (
unsigned short)((loc_result >> 16) & 0xffff);
134 buffer->x[2] = (
unsigned short)((loc_result >> 32) & 0xffff);
137 X = (Uint64)buffer->x[2] << 16 |
138 (Uint64)buffer->x[1] >> 16;
139 a = (Uint64)buffer->a[2] << 16 |
140 (Uint64)buffer->a[1] >> 16;
142 loc_result = X * a + buffer->c;
144 buffer->x[0] = (
unsigned short)(loc_result >> 16 & 0xffffffffl);
145 buffer->x[1] = (
unsigned short)(loc_result << 16 & 0xffff0000l);
151 if (
sizeof (
unsigned short int) == 2)
152 *result = buffer->x[2] << 15 | buffer->x[1] >> 1;
154 *result = buffer->x[2] >> 1;
165 for(i = 0; i < seq->length; i++ ) {
166 j = myRandom48(seq->length);
168 tmp = seq->values[
i];
169 seq->values[
i] = seq->values[j];
170 seq->values[j] = tmp;
183 double getTps(
unsigned int count,
double timeValue)
187 if( timeValue != 0.0 )
188 f = count / timeValue;
202 unsigned int totalLength;
205 if( !seq || !inputValues )
return(-1);
212 for(i = 0; inputValues[
i].length != 0; i++)
213 totalLength += inputValues[i].length;
215 if( totalLength == 0 )
return(-1);
217 seq->length = totalLength;
218 seq->values = calloc(totalLength,
sizeof(
unsigned int));
220 if( seq->values == 0 )
return(-1);
227 for(i = 0; inputValues[
i].length != 0; i++) {
228 for(j = 0; j < inputValues[
i].length; j++ ) {
229 seq->values[idx] = inputValues[
i].value;
234 shuffleSequence(seq);
236 seq->currentIndex = 0;
243 unsigned int nextValue;
245 nextValue = seq->values[seq->currentIndex];
249 if(seq->currentIndex == seq->length){
250 seq->currentIndex = 0;
251 shuffleSequence(seq);
263 for(i = 0; i<seq->length; i++) {
264 ndbout_c(
"%d ", seq->values[i]);
266 if((i+1) % numPerRow == 0)
270 if(i % numPerRow != 0)
274 void myRandom48Init(
long int seedval)
276 localRandom48Init(seedval, &dRand48Data);
279 long int myRandom48(
unsigned int maxValue)
283 localRandom48(&dRand48Data, &result);
285 return(result % maxValue);