too simple C clang program
source code
/* The Computer Language Benchmarks Game
https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
*/
#include<stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
// mtime side-effect
FILE* f = fopen("./one", "w"); fclose(f);
long n = atol(argv[1]);
double sum = 0.0;
double flip = -1.0;
for (long i = 1; i <= n; i++) {
flip *= -1.0;
sum += flip / (2*i - 1);
}
printf("%.9f\n", sum*4.0);
// mtime side-effect
f = fopen("./two", "w"); fclose(f);
return 0;
}
notes, command-line, and program output
NOTES:
64-bit Ubuntu quad core
Ubuntu clang version 18.1.8 (11)
Wed, 23 Oct 2024 01:52:59 GMT
MAKE:
/usr/bin/clang -pipe -Wall -O3 -fomit-frame-pointer -march=ivybridge toosimple.c -o toosimple.clang_run
rm toosimple.c
5.61s to complete and log all make actions
COMMAND LINE:
./toosimple.clang_run 10000000000
PROGRAM OUTPUT:
3.141592653