15 #include <freerdp/config.h>
17 #include "prim_test.h"
22 #include <sys/types.h>
26 #include <winpr/sysinfo.h>
27 #include <winpr/platform.h>
28 #include <winpr/crypto.h>
32 BOOL g_TestPrimitivesPerformance = FALSE;
33 UINT32 g_Iterations = 1000;
35 int test_sizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
39 float measure_delta_time(UINT64 t0, UINT64 t1)
41 INT64 diff = (INT64)(t1 - t0);
42 double retval = diff / 1000000000.0;
43 return (retval < 0.0) ? 0.0f : (float)retval;
47 void measure_floatprint(
float t,
char* output,
size_t len)
57 i = ((int)(t / f + 0.5f)) * (
int)f;
60 (void)_snprintf(output, len,
"%f", t);
62 (void)_snprintf(output, len,
"%d", (
int)(t + 0.5f));
64 (void)_snprintf(output, len,
"%3d", i);
66 (void)_snprintf(output, len,
"%3d,%03d", i / 1000, i % 1000);
68 (void)_snprintf(output, len,
"%3d,%03d,000", i / 1000000, (i % 1000000) / 1000);
70 (void)_snprintf(output, len,
"%3d,%03d,000,000", i / 1000000000,
71 (i % 1000000000) / 1000000);
73 (
void)_snprintf(output, len,
"%f", t);
76 void prim_test_setup(BOOL performance)
78 generic = primitives_get_generic();
79 optimized = primitives_get();
80 g_TestPrimitivesPerformance = performance;
83 BOOL speed_test(
const char* name,
const char* dsc, UINT32 iterations, speed_test_fkt
generic,
84 speed_test_fkt optimized, ...)
86 if (!name || !
generic || !optimized || (iterations == 0))
89 for (UINT32 i = 0; i < iterations; i++)