Last change
on this file since 7a29392f was
1188195,
checked in by Dmitry Kobets <dkobets@…>, 5 years ago
|
Finished floating point vec2
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1188195] | 1 | #include "../../libcfa/src/vec/vec2.hfa" |
---|
| 2 | /* #include <fstream.hfa> */ |
---|
| 3 | /* #define BENCH_N 1000000 */ |
---|
| 4 | #include "../bench.h" |
---|
| 5 | |
---|
| 6 | int main(int argc, char* argv[]) { |
---|
| 7 | volatile vec2(float) v1 = {1,2}; |
---|
| 8 | volatile vec2(float) v2 = {20.5f, 30.2f}; |
---|
| 9 | |
---|
| 10 | { |
---|
| 11 | BENCH( |
---|
| 12 | for (n) { |
---|
| 13 | volatile float res = dot(v1, v2); |
---|
| 14 | asm volatile ("":::"memory"); |
---|
| 15 | }, |
---|
| 16 | dot_b |
---|
| 17 | ); |
---|
| 18 | printf("dot: %g\n", dot_b); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | { |
---|
| 22 | BENCH( |
---|
| 23 | for (n) { |
---|
| 24 | volatile vec2(float) res = v1 + v2; |
---|
| 25 | asm volatile ("":::"memory"); |
---|
| 26 | }, |
---|
| 27 | add_b |
---|
| 28 | ); |
---|
| 29 | printf("vector addition: %g\n", add_b); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | { |
---|
| 33 | BENCH( |
---|
| 34 | for (n) { |
---|
| 35 | volatile vec2(float) res = normalize(v1); |
---|
| 36 | asm volatile ("":::"memory"); |
---|
| 37 | }, |
---|
| 38 | normalize_b |
---|
| 39 | ); |
---|
| 40 | printf("normalize: %g\n", normalize_b); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | { |
---|
| 44 | BENCH( |
---|
| 45 | for (n) { |
---|
| 46 | volatile vec2(float) res = reflect(v1, v2); |
---|
| 47 | asm volatile ("":::"memory"); |
---|
| 48 | }, |
---|
| 49 | reflect_b |
---|
| 50 | ); |
---|
| 51 | printf("reflect : %g\n", reflect_b); |
---|
| 52 | } |
---|
| 53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.