Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Last active Feb 5, 2022
Embed
What would you like to do?
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