Тестирование производительности: версоры + матрица + поворот

This commit is contained in:
Andrey Pokidov 2024-11-27 02:51:07 +07:00
parent 5d4472150b
commit a30629df67
3 changed files with 78 additions and 4 deletions

View file

Internal server error - Personal Git Server: Beyond coding. We Forge.

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -9,6 +9,45 @@
#include <time.h> #include <time.h>
#endif // _WINDOWS_ #endif // _WINDOWS_
BgFP32Vector3* allocate_vectors3(const unsigned int amount)
{
return calloc(amount, sizeof(BgFP32Vector3));
}
BgFP32Vector3* make_zero_vectors3(const unsigned int amount)
{
BgFP32Vector3* list = allocate_vectors3(amount);
if (list == 0) {
return 0;
}
for (unsigned int i = 0; i < amount; i++) {
bg_fp32_vector3_reset(&list[i]);
}
return list;
}
BgFP32Vector3* make_random_vectors3(const unsigned int amount)
{
BgFP32Vector3* list = allocate_vectors3(amount);
if (list == 0) {
return 0;
}
const float multiplier = 2.0f / RAND_MAX;
for (unsigned int i = 0; i < amount; i++) {
list[i].x1 = rand() * multiplier - 1.0f;
list[i].x2 = rand() * multiplier - 1.0f;
list[i].x3 = rand() * multiplier - 1.0f;
}
return list;
}
BgFP32Versor* allocate_versors(const unsigned int amount) BgFP32Versor* allocate_versors(const unsigned int amount)
{ {
return calloc(amount, sizeof(BgFP32Versor)); return calloc(amount, sizeof(BgFP32Versor));
@ -160,6 +199,27 @@ int main()
return 0; return 0;
} }
BgFP32Matrix3x3* matrixes =malloc(amount * sizeof(BgFP32Matrix3x3));
if (matrixes == 0) {
printf("Cannot allocate memory for matrixes");
free(results);
free(versors2);
free(versors1);
return 0;
}
BgFP32Vector3* vectors = make_random_vectors3(amount);
if (results == 0) {
printf("Cannot allocate memory for result vectors");
free(matrixes);
free(results);
free(versors2);
free(versors1);
return 0;
}
#ifdef _WIN64 #ifdef _WIN64
end = GetTickCount64(); end = GetTickCount64();
printf("Setup time: %lld\n", end - now); printf("Setup time: %lld\n", end - now);
@ -173,9 +233,9 @@ int main()
#endif // _WIN64 #endif // _WIN64
for (int j = 0; j < 1000; j++) { for (int j = 0; j < 1000; j++) {
for (unsigned int i = 0; i < amount; i++) { for (unsigned int i = 0; i < amount; i++) {
bg_fp32_versor_shorten(&versors1[i]); bg_fp32_versor_combine(&versors1[i], &versors2[i], &results[i]);