c-uebungen/Assignment_022/solution/vector_heap_benchmark.c

36 lines
674 B
C
Raw Permalink Normal View History

2023-05-21 21:10:46 +02:00
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "vector_heap.h"
#include "benchmark.h"
int main(int argv, char** argc) {
clock_t before, after;
before = clock();
Vector *v1, *v2, *v3, *v4, *v5;
v1 = vec_new(10, 20, 30);
v2 = vec_new(-20, 99, 38);
for (long long i = 0; i < RUNS; i++) {
v3 = vec_mul_cross(v1, v2);
vec_mul_dot(v3, v2);
v4 = vec_mul_scalar(v3, 10.0);
v5 = vec_mul_scalar(v3, 0.1);
free(v3);
free(v4);
free(v5);
}
free(v1);
free(v2);
after = clock();
printf("Runtime: %.3f seconds\n", (after - before) / (double) CLOCKS_PER_SEC);
}