Skip to content

Instantly share code, notes, and snippets.

@itisravi
Created April 20, 2011 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itisravi/930990 to your computer and use it in GitHub Desktop.
Save itisravi/930990 to your computer and use it in GitHub Desktop.
plain.c
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#define SIZE (4*1000)
void double_elements(unsigned int *ptr, unsigned int size);
int main(void)
{
struct timeval tv1,tv2;
unsigned int i;
unsigned int input_array[SIZE];
for(i=0;i<SIZE;i++)
{
input_array[i]=i+1;
#ifdef DEBUG
printf("Input:%d\n",input_array[i]);
#endif
}
gettimeofday(&tv1,NULL);
double_elements(input_array,SIZE);
gettimeofday(&tv2,NULL);
printf("\n");
#ifdef DEBUG
for(i=0;i<SIZE;i++)
printf("Output:%d\n",input_array[i]);
#endif
printf("Time for compute : %d microseconds\n", tv2.tv_usec - tv1.tv_usec +1000000 * (tv2.tv_sec - tv1.tv_sec));
return 0;
}
void double_elements(unsigned int *ptr, unsigned int size)
{
unsigned int loop;
for( loop= 0; loop<size; loop++)
ptr[loop]<<=1;
return;
}
@itisravi
Copy link
Author

arm-v7a8-linux-gnueabi-gcc plain.c -o plain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment