Revision [7673]
This is an old revision of GnuCompilerFloatingPointBenchmark made by ToBo on 2009-01-30 22:51:57.
Floating Point Benchmark
Floating point benchmark with GNU compiler
#include <cstdio>
#include <cstdlib>
#include <ctime>
#define TIC (start = clock())
#define TAC (zeit = clock() - start)
#define COUNT 20000000
//-------- main -------------------------------------------------------
int main( int argc, char *argv[] )
{
long long unsigned int i;
float fpSingle;
double fpDouble;
long double fpDoubleExt;
clock_t start, zeit;
puts("||IEEE 754 ||Zeit (Sekunden)||");
TIC;
for (i=0; i<COUNT; i++)
{
fpSingle = fpSingle * (fpSingle - (fpSingle / 7)) + ((float)5);
}
TAC;
printf("||Single ||%.2f s||\n", (double)zeit/CLOCKS_PER_SEC);
TIC;
for (i=0; i<COUNT; i++)
{
fpDouble = fpDouble * (fpDouble - (fpDouble / 7)) + ((double)5);
}
TAC;
printf("||Double ||%.2f s||\n", (double)zeit/CLOCKS_PER_SEC);
TIC;
for (i=0; i<COUNT; i++)
{
fpDoubleExt = fpDoubleExt * (fpDoubleExt - (fpDoubleExt / 7)) + ((long double)5);
}
TAC;
printf("||Double Extended ||%.2f s||\n", (double)zeit/CLOCKS_PER_SEC);
return 0;
}
#include <cstdlib>
#include <ctime>
#define TIC (start = clock())
#define TAC (zeit = clock() - start)
#define COUNT 20000000
//-------- main -------------------------------------------------------
int main( int argc, char *argv[] )
{
long long unsigned int i;
float fpSingle;
double fpDouble;
long double fpDoubleExt;
clock_t start, zeit;
puts("||IEEE 754 ||Zeit (Sekunden)||");
TIC;
for (i=0; i<COUNT; i++)
{
fpSingle = fpSingle * (fpSingle - (fpSingle / 7)) + ((float)5);
}
TAC;
printf("||Single ||%.2f s||\n", (double)zeit/CLOCKS_PER_SEC);
TIC;
for (i=0; i<COUNT; i++)
{
fpDouble = fpDouble * (fpDouble - (fpDouble / 7)) + ((double)5);
}
TAC;
printf("||Double ||%.2f s||\n", (double)zeit/CLOCKS_PER_SEC);
TIC;
for (i=0; i<COUNT; i++)
{
fpDoubleExt = fpDoubleExt * (fpDoubleExt - (fpDoubleExt / 7)) + ((long double)5);
}
TAC;
printf("||Double Extended ||%.2f s||\n", (double)zeit/CLOCKS_PER_SEC);
return 0;
}
@Amygdala
IEEE 754 | Zeit (Sekunden) |
Single | 14.68 s |
Double | 14.71 s |
Double Extended | 15.44 s |
Siehe auch • • •