Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Last active February 5, 2022 18:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaityo256/2ddfd806f7368967fa2ee04f33732f20 to your computer and use it in GitHub Desktop.
Save kaityo256/2ddfd806f7368967fa2ee04f33732f20 to your computer and use it in GitHub Desktop.
Trad vs. Clang
#include <algorithm>
#include <random>
#include <cstdio>
int main(void) {
std::mt19937 mt(1);
int s = 0;
for (int i = 0; i < 100; i++) {
std::uniform_real_distribution<double> ud(0.0, 1.0);
for(int j=0;j<10000;j++){
if(ud(mt) < 0.5){
s +=1;
}
}
}
printf("%d\n",s);
}
@kaityo256
Copy link
Author

kaityo256 commented Feb 4, 2022

Compile.

FCCpx -Kfast main.cpp -o trad.out
FCCpx -Kfast -Nclang main.cpp -o clang.out

Run.

$ time ./trad.out
499042

real    0m0.101s
user    0m0.068s
sys     0m0.022s

$ time ./clang.out
499042

real    0m2.964s
user    0m2.938s
sys     0m0.020s

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