Create a gist now

Instantly share code, notes, and snippets.

@tomaes /csrt.c
Created Mar 23, 2016

...turns out PDE is slower than expected; doing the same thing in c99 (-O3'ed) is an order of magnitude faster?
// 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