Skip to content

Instantly share code, notes, and snippets.

@hltbra
Created June 25, 2012 16:53
Show Gist options
  • Select an option

  • Save hltbra/2989843 to your computer and use it in GitHub Desktop.

Select an option

Save hltbra/2989843 to your computer and use it in GitHub Desktop.
Perfomance example [b]
#include <string.h>
enum {
BIG = 1000000,
SMALL = 1000
};
int main() {
int i, j;
unsigned a[BIG], b[BIG];
memset(a, 0, BIG);
memset(b, 0, BIG);
for (i = 0 ; i < BIG ; i++) {
for (j = 0 ; j < SMALL ; j++) {
a[i] += b[i] + 10;
}
}
}
/*
* $ gcc -o b.out b.c
* $ time ./b.out
* ./b.out 2.93s user 0.01s system 99% cpu 2.943 total
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment