Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created February 4, 2022 14:30
Show Gist options
  • Save kaityo256/9392bb3984afcdd45d0cb868036788fd to your computer and use it in GitHub Desktop.
Save kaityo256/9392bb3984afcdd45d0cb868036788fd to your computer and use it in GitHub Desktop.
Trad vs. Clang
#include <cstdio>
#include <algorithm>
#include <random>
int main(){
std::mt19937 mt;
double s = 0.0;
std::uniform_real_distribution<double> ud(0.0, 1.0);
for (int i = 0; i < 1000000; i++) s+=ud(mt);
printf("%f\n",s);
}
@kaityo256
Copy link
Author

Compile.

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

Run (in the interactive queue).

$ time ./trad.out
500044.868973

real    0m0.102s
user    0m0.061s
sys     0m0.029s

$ time ./clang.out
500044.868973

real    0m2.965s
user    0m2.928s
sys     0m0.030s

@kaityo256
Copy link
Author

In the interactive queue.

$ g++ -O3 -std=c++11 main.cpp -o gcc.out
$ time ./a.out
$ time ./gcc.out
500044.868973

real    0m0.256s
user    0m0.255s
sys     0m0.000s

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