diff options
| author | flatmush <flatmush@d3e1167c-abe1-51d5-8199-f9061ebe54e4> | 2011-02-25 12:08:03 +0000 |
|---|---|---|
| committer | flatmush <flatmush@d3e1167c-abe1-51d5-8199-f9061ebe54e4> | 2011-02-25 12:08:03 +0000 |
| commit | 8cbe9b3f9ba031773aea33e41ba1b7e77802beba (patch) | |
| tree | f57780d70e9264f9cf13e9dd46a78ac8645a5c41 /fixtest/main.c | |
| parent | 7c2852e7f647ffad35eeda527d4c9d6bff96f226 (diff) | |
| download | libfixmath-8cbe9b3f9ba031773aea33e41ba1b7e77802beba.tar.gz | |
Added fix16_exp currently using the Taylor Series algorithm off Wikipedia, if anyone can optimize this better then go ahead.
Modified fixtest to be a little more generic, can now easily change which function it tests.
Diffstat (limited to 'fixtest/main.c')
| -rw-r--r-- | fixtest/main.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/fixtest/main.c b/fixtest/main.c index a7e9e89..93c945b 100644 --- a/fixtest/main.c +++ b/fixtest/main.c @@ -8,6 +8,17 @@ #include "hiclock.h"
+//#define fix_func fix16_exp
+//#define fix_func_str "fix16_exp"
+//#define flt_func expf
+//#define flt_func_str "expf"
+
+#define fix_func fix16_atan
+#define fix_func_str "fix16_atan"
+#define flt_func atanf
+#define flt_func_str "atanf"
+
+
int main(int argc, char** argv) {
printf("libfixmath test tool\n");
@@ -16,7 +27,7 @@ int main(int argc, char** argv) { uintptr_t args = (1 << 8);
uintptr_t iter = (1 << 8);
- uintptr_t pass = (1 << 8);
+ uintptr_t pass = (1 << 6);
uintptr_t i;
srand(time(NULL));
@@ -35,7 +46,7 @@ int main(int argc, char** argv) { for(i = 0; i < iter; i++) {
uintptr_t j;
for(j = 0; j < args; j++)
- fix_result[j] = fix16_atan(fix_args[j]);
+ fix_result[j] = fix_func(fix_args[j]);
}
hiclock_t fix_end = hiclock();
@@ -47,7 +58,7 @@ int main(int argc, char** argv) { for(i = 0; i < iter; i++) {
uintptr_t j;
for(j = 0; j < args; j++)
- flt_result[j] = atanf(flt_args[j]);
+ flt_result[j] = flt_func(flt_args[j]);
}
hiclock_t flt_end = hiclock();
@@ -57,10 +68,10 @@ int main(int argc, char** argv) { fix_duration += (fix_end - fix_start);
}
- printf("Floating Point: %08"PRIuHICLOCK" @ %"PRIu32"Hz\n", flt_duration, HICLOCKS_PER_SEC);
- printf("Fixed Point: %08"PRIuHICLOCK" @ %"PRIu32"Hz\n", fix_duration, HICLOCKS_PER_SEC);
- printf("Difference: %08"PRIiHICLOCK" (% 3.2f%%)\n", (flt_duration - fix_duration), ((fix_duration * 100.0) / flt_duration));
- printf("Error: %f%%\n", ((fix16_to_dbl(fix_error) * 100.0) / (args * pass)));
+ printf("% 16s: %08"PRIuHICLOCK" @ %"PRIu32"Hz\n", fix_func_str, flt_duration, HICLOCKS_PER_SEC);
+ printf("% 16s: %08"PRIuHICLOCK" @ %"PRIu32"Hz\n", fix_func_str, fix_duration, HICLOCKS_PER_SEC);
+ printf(" Difference: %08"PRIiHICLOCK" (% 3.2f%%)\n", (flt_duration - fix_duration), ((fix_duration * 100.0) / flt_duration));
+ printf(" Error: %f%%\n", ((fix16_to_dbl(fix_error) * 100.0) / (args * pass)));
return EXIT_SUCCESS;
}
|
