Skip to content

Commit 5234991

Browse files
committed
Saving...
1 parent 3053dc7 commit 5234991

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

example.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ size_t compress(uint32_t * datain, size_t length, uint8_t * buffer) {
2424

2525

2626
int main() {
27-
int N = 5000 * SIMDBlockSize;//SIMDBlockSize is 128
27+
int REPEAT = 5;
28+
int N = 1000000 * SIMDBlockSize;//SIMDBlockSize is 128
2829
uint32_t * datain = malloc(N * sizeof(uint32_t));
2930
size_t compsize;
3031
clock_t start, end;
@@ -39,20 +40,22 @@ int main() {
3940
uint32_t offset = 0;
4041
compsize = compress(datain,N,buffer);
4142
printf("compression rate = %f \n", (N * sizeof(uint32_t))/ (compsize * 1.0 ));
42-
uint8_t * decbuffer = buffer;
4343
start = clock();
4444
uint32_t bogus = 0;
45-
for (int k = 0; k * SIMDBlockSize < N; ++k) {
45+
for(int repeat = 0; repeat < REPEAT; ++repeat) {
46+
uint8_t * decbuffer = buffer;
47+
for (int k = 0; k * SIMDBlockSize < N; ++k) {
4648
uint8_t b = *decbuffer++;
4749
simdunpackd1(offset, (__m128i *) decbuffer, backbuffer, b);
4850
// do something here with backbuffer
4951
bogus += backbuffer[3];
5052
decbuffer += b * sizeof(__m128i);
5153
offset = backbuffer[SIMDBlockSize - 1];
54+
}
5255
}
5356
end = clock();
5457
double numberofseconds = (end-start)/(double)CLOCKS_PER_SEC;
55-
printf("decoding speed in million of integers per second %f \n",N/(numberofseconds*1000.0*1000.0));
58+
printf("decoding speed in million of integers per second %f \n",N*REPEAT/(numberofseconds*1000.0*1000.0));
5659
printf("ignore me %i \n",bogus);
5760
}
5861
free(buffer);

0 commit comments

Comments
 (0)