-
-
Save iax7/0f25308f2c9e42081459979f77d91365 to your computer and use it in GitHub Desktop.
Script mostrado en https://www.lastdragon.net/?p=2260
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
# https://www.lastdragon.net/?p=2260 | |
cat > programa.c << EOF | |
#include <stdio.h> | |
double powern(double d, unsigned n) | |
{ | |
double x = 1.0; | |
unsigned j; | |
for (j = 1; j <= n; j++) | |
x *= d; | |
return x; | |
} | |
int main(void) | |
{ | |
double sum = 0.0; | |
unsigned i; | |
for (i = 1; i <= 1000000000; i++) | |
{ | |
sum += powern (i, i % 5); | |
} | |
printf ("sum = %g\n", sum); | |
return 0; | |
} | |
EOF | |
echo "Compilando y ejecutando sin optimizacion" | |
gcc -Wall -O0 programa.c -lm -o programa | |
ls -l programa | |
time ./programa | |
rm -f programa | |
echo "" | |
echo "Compilando y Optimizando nivel 1" | |
gcc -Wall -O1 programa.c -lm -o programa | |
ls -l programa | |
time ./programa | |
rm -f programa | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment