-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.cpp
76 lines (52 loc) · 1.88 KB
/
benchmark.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// File-tester.
// Checks speed of calculus of different functions.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "setCalculationFunctions.h"
const int WIDTH = 1920;
const int HEIGHT = 1080;
const int ATTEMPTS = 20;
int main()
{
mandelbrot set = {};
set.pixels = (int *)calloc(WIDTH * HEIGHT, sizeof(int));
time_t start;
// No optimization render.
/////////////////////////////////////////////////////////
start = clock() / CLOCKS_PER_SEC;
for (int index = 0; index < ATTEMPTS; index++)
renderSetNoOptimization(WIDTH, HEIGHT, &set);
printf("%-25s%f\n", "TIME NO OPTIMIZATION:", ((float)clock() / CLOCKS_PER_SEC - start) / ATTEMPTS);
// Render with SSE.
/////////////////////////////////////////////////////////
start = clock() / CLOCKS_PER_SEC;
for (int index = 0; index < ATTEMPTS; index++)
renderSetSSE(WIDTH, HEIGHT, &set);
printf("%-25s%f\n", "TIME SSE:", ((float)clock() / CLOCKS_PER_SEC - start) / ATTEMPTS);
// Render with AVX.
/////////////////////////////////////////////////////////
start = clock() / CLOCKS_PER_SEC;
for (int index = 0; index < ATTEMPTS; index++)
renderSetAVX(WIDTH, HEIGHT, &set);
printf("%-25s%f\n", "TIME AVX:", ((float)clock() / CLOCKS_PER_SEC - start) / ATTEMPTS);
// Render with AVX512.
/////////////////////////////////////////////////////////
if (IsAVX512InTouch())
{
start = clock();
renderSetAVX512f(WIDTH, HEIGHT, &set);
printf("TIME AVX512: %f\n", ((float)clock() / CLOCKS_PER_SEC - start) / ATTEMPTS);
// Render with AVX512F
/////////////////////////////////////////////////////////
start = clock() / CLOCKS_PER_SEC;
for (int index = 0; index < ATTEMPTS; index++)
renderSetAVX512f(WIDTH, HEIGHT, &set);
printf("%-25s%f\n", "TIME AVX512:", ((float)clock() / CLOCKS_PER_SEC - start) / ATTEMPTS);
}
else
{
printf("AVX512 is not supported\n");
}
return 0;
}