Created
March 23, 2016 21:21
-
-
Save tomaes/690868049c4aa81b85e1 to your computer and use it in GitHub Desktop.
...turns out PDE is slower than expected; doing the same thing in c99 (-O3'ed) is an order of magnitude faster?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c99 | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <time.h> | |
#define COUNT 200000000 | |
#define RND_RANGE 200000000 | |
//#define OUTPUT | |
int32_t ip[COUNT]; | |
int32_t op[RND_RANGE]; | |
int32_t main() | |
{ | |
srand( time(NULL) ); | |
printf("generating PRN array[%i], range: %i\n", COUNT, RND_RANGE); | |
for( int32_t i = 0; i < COUNT; i++ ) | |
{ | |
ip[i] = rand() % RND_RANGE; | |
} | |
memset(op, 0, sizeof(op) ); | |
printf("sorting PRN array...\n"); | |
for( int32_t i = 0; i < COUNT; i++ ) | |
{ | |
op[ ip[i] ]++; | |
} | |
#ifdef OUTPUT | |
printf("output: \n"); | |
for( int32_t i = 0; i < RND_RANGE; i++ ) | |
{ | |
if (op[i] > 0) printf("%i(%i)\t", i, op[i] ); | |
} | |
#endif // OUTPUT | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment