aboutsummaryrefslogtreecommitdiff
path: root/fixtest
diff options
context:
space:
mode:
authorflatmush <flatmush@d3e1167c-abe1-51d5-8199-f9061ebe54e4>2011-02-25 12:08:03 +0000
committerflatmush <flatmush@d3e1167c-abe1-51d5-8199-f9061ebe54e4>2011-02-25 12:08:03 +0000
commit8cbe9b3f9ba031773aea33e41ba1b7e77802beba (patch)
treef57780d70e9264f9cf13e9dd46a78ac8645a5c41 /fixtest
parent7c2852e7f647ffad35eeda527d4c9d6bff96f226 (diff)
downloadlibfixmath-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')
-rw-r--r--fixtest/fixtest.depend37
-rw-r--r--fixtest/fixtest.layout10
-rw-r--r--fixtest/main.c25
3 files changed, 58 insertions, 14 deletions
diff --git a/fixtest/fixtest.depend b/fixtest/fixtest.depend
index db7e8ce..2822106 100644
--- a/fixtest/fixtest.depend
+++ b/fixtest/fixtest.depend
@@ -1,5 +1,5 @@
# depslib dependency file v1.0
-1298567472 source:g:\vrfx\libfixmath\fixtest\main.c
+1298635002 source:g:\vrfx\libfixmath\fixtest\main.c
<stdio.h>
<stdlib.h>
<math.h>
@@ -19,7 +19,7 @@
1298453688 g:\vrfx\libfixmath\\libfixmath\fract32.h
<stdint.h>
-1298454206 g:\vrfx\libfixmath\\libfixmath\fix16.h
+1298634082 g:\vrfx\libfixmath\\libfixmath\fix16.h
<stdint.h>
1298562746 source:g:\vrfx\libfixmath\fixtest\hiclock.c
@@ -32,3 +32,36 @@
<windows.h>
<time.h>
+1298567472 source:i:\vrfx\libfixmath\fixtest\main.c
+ <stdio.h>
+ <stdlib.h>
+ <math.h>
+ <time.h>
+ <inttypes.h>
+ <libfixmath/fixmath.h>
+ "hiclock.h"
+
+1298453688 i:\vrfx\libfixmath\\libfixmath\fixmath.h
+ "uint32.h"
+ "fract32.h"
+ "fix16.h"
+
+1298453688 i:\vrfx\libfixmath\\libfixmath\uint32.h
+ <stdint.h>
+
+1298453688 i:\vrfx\libfixmath\\libfixmath\fract32.h
+ <stdint.h>
+
+1298577432 i:\vrfx\libfixmath\\libfixmath\fix16.h
+ <stdint.h>
+
+1298564182 i:\vrfx\libfixmath\fixtest\hiclock.h
+ <stdint.h>
+ <inttypes.h>
+ <sys/time.h>
+ <windows.h>
+ <time.h>
+
+1298562746 source:i:\vrfx\libfixmath\fixtest\hiclock.c
+ "hiclock.h"
+
diff --git a/fixtest/fixtest.layout b/fixtest/fixtest.layout
index 6606349..36f21e7 100644
--- a/fixtest/fixtest.layout
+++ b/fixtest/fixtest.layout
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
- <ActiveTarget name="dbg" />
- <File name="hiclock.c" open="1" top="0" tabpos="3">
+ <ActiveTarget name="rel" />
+ <File name="hiclock.c" open="1" top="0" tabpos="6">
<Cursor position="520" topLine="0" />
</File>
- <File name="hiclock.h" open="1" top="0" tabpos="2">
+ <File name="hiclock.h" open="1" top="0" tabpos="5">
<Cursor position="578" topLine="0" />
</File>
- <File name="main.c" open="1" top="1" tabpos="1">
- <Cursor position="139" topLine="30" />
+ <File name="main.c" open="1" top="1" tabpos="4">
+ <Cursor position="392" topLine="36" />
</File>
</CodeBlocks_layout_file>
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;
}