Рефакторинг и оптимизация вычислений / Refactoring and optimization of computations

This commit is contained in:
Andrey Pokidov 2024-11-26 02:25:04 +07:00
parent 03e390c1d0
commit 2655e43cb4
15 changed files with 810 additions and 829 deletions

View file

@ -52,7 +52,7 @@ BgFP32Versor * make_random_versors(const unsigned int amount)
void print_versor(const BgFP32Versor* versor)
{
printf("(%f, %f, %f, %f)\n", versor->s0, versor->x1, versor->x2, versor->x3);
printf("Versor (%f, %f, %f, %f); Delta = %e\n", versor->s0, versor->x1, versor->x2, versor->x3, bg_fp32_versor_get_modulus(versor) - 1.0f);
}
void print_vector(const BgFP32Vector3* vector)
@ -125,11 +125,11 @@ int main()
const unsigned int amount = 1000000;
#ifdef _WIN64
ULONGLONG now;
ULONGLONG now, start, end;
now = GetTickCount64();
srand((unsigned int)(now & 0xfffffff));
#else
struct timespec now;
struct timespec now, start, end;
clock_gettime(0, &now);
srand((unsigned int)(now.tv_nsec & 0xfffffff));
#endif // _WIN64
@ -159,10 +159,14 @@ int main()
}
#ifdef _WIN64
ULONGLONG start, end;
end = GetTickCount64();
printf("Setup time: %lld\n", end - now);
start = GetTickCount64();
#else
struct timespec start, end;
clock_gettime(CLOCK_REALTIME, &end);
printf("Time: %lf\n", (end.tv_sec - now.tv_sec) * 1000.0 + (end.tv_nsec - now.tv_nsec) * 0.000001);
clock_gettime(CLOCK_REALTIME, &start);
#endif // _WIN64
for (int j = 0; j < 1000; j++) {