00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00045
00046 #include <benchs.h>
00047
00048
00049 double a = 3.141592;
00050 float f = 3.141592;
00051
00052
00053 void
00054 bench_float (bench_t *b)
00055 {
00056 long n;
00057
00058 bench_start (b);
00059 f = f * f;
00060 bench_stop (b);
00061 bench_report (b, "Float mul (%d)", (long) f);
00062
00063 bench_start (b);
00064 f = f + f;
00065 bench_stop (b);
00066 bench_report (b, "Float add (%d)", (long) f);
00067
00068 bench_start (b);
00069 f = -f;
00070 bench_stop (b);
00071 bench_report (b, "Float neg (%d)", (long) f);
00072
00073 bench_start (b);
00074 f = f / 0.1;
00075 bench_stop (b);
00076 bench_report (b, "Float div (%d)", (long) f);
00077
00078 f = f + 2.0;
00079 bench_start (b);
00080 n = f;
00081 bench_stop (b);
00082 bench_report (b, "Float to long (%d)", n);
00083
00084 n += 2;
00085 bench_start (b);
00086 f = n;
00087 bench_stop (b);
00088 bench_report (b, "Long to float (%d)", n);
00089 }
00090
00091
00092 void
00093 bench_double (bench_t *b)
00094 {
00095 long n;
00096
00097 bench_start (b);
00098 a = a * a;
00099 bench_stop (b);
00100 bench_report (b, "Double mul (%d)", (long) a);
00101
00102 bench_start (b);
00103 a = a + a;
00104 bench_stop (b);
00105 bench_report (b, "Double add (%d)", (long) a);
00106
00107 bench_start (b);
00108 a = -a;
00109 bench_stop (b);
00110 bench_report (b, "Double neg (%d)", (long) a);
00111
00112 bench_start (b);
00113 a = a / 0.1;
00114 bench_stop (b);
00115 bench_report (b, "Double div (%d)", (long) a);
00116
00117 a = a + 3.1;
00118 bench_start (b);
00119 n = a;
00120 bench_stop (b);
00121 bench_report (b, "Double to long (%d)", n);
00122
00123 n += 2;
00124 bench_start (b);
00125 a = n;
00126 bench_stop (b);
00127 bench_report (b, "Long to double (%d)", (long) a);
00128 }
00129
00130
00131 int
00132 main ()
00133 {
00134 bench_t b;
00135
00136 bench_init (&b);
00137 bench_float (&b);
00138 bench_double (&b);
00139
00140 return 0;
00141 }