Skip to content

Commit

Permalink
Saving...
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed May 19, 2014
1 parent 3053dc7 commit 5234991
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ size_t compress(uint32_t * datain, size_t length, uint8_t * buffer) {


int main() {
int N = 5000 * SIMDBlockSize;//SIMDBlockSize is 128
int REPEAT = 5;
int N = 1000000 * SIMDBlockSize;//SIMDBlockSize is 128
uint32_t * datain = malloc(N * sizeof(uint32_t));
size_t compsize;
clock_t start, end;
Expand All @@ -39,20 +40,22 @@ int main() {
uint32_t offset = 0;
compsize = compress(datain,N,buffer);
printf("compression rate = %f \n", (N * sizeof(uint32_t))/ (compsize * 1.0 ));
uint8_t * decbuffer = buffer;
start = clock();
uint32_t bogus = 0;
for (int k = 0; k * SIMDBlockSize < N; ++k) {
for(int repeat = 0; repeat < REPEAT; ++repeat) {
uint8_t * decbuffer = buffer;
for (int k = 0; k * SIMDBlockSize < N; ++k) {
uint8_t b = *decbuffer++;
simdunpackd1(offset, (__m128i *) decbuffer, backbuffer, b);
// do something here with backbuffer
bogus += backbuffer[3];
decbuffer += b * sizeof(__m128i);
offset = backbuffer[SIMDBlockSize - 1];
}
}
end = clock();
double numberofseconds = (end-start)/(double)CLOCKS_PER_SEC;
printf("decoding speed in million of integers per second %f \n",N/(numberofseconds*1000.0*1000.0));
printf("decoding speed in million of integers per second %f \n",N*REPEAT/(numberofseconds*1000.0*1000.0));
printf("ignore me %i \n",bogus);
}
free(buffer);
Expand Down

0 comments on commit 5234991

Please sign in to comment.