Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2010 12:39
Show Gist options
  • Select an option

  • Save anonymous/716660 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/716660 to your computer and use it in GitHub Desktop.
inline int max(int a, int b){
//return a > b ? a : b;
//return (-(a>b))&a|(~(-(a>b)))&b;
int c=a>b; return c*a+!c*b;
}
int main(int argc, char** argv)
{
int xs[10000];
for(int i = 0; i < 10000; i++){
xs[i] = xor128();
}
int dummy = 0;
TimeStat t("sample");
for(int iter = 0; iter < 20; iter++){
t.start();
for(int i = 0; i < 10000; i++){
for(int j = 0; j < 10000; j++){
dummy += max(xs[i], xs[j]);
}
}
t.end();
}
t.print();
printf("dummy: %d\n", dummy);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment