Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHenrik Gramner <gramner@twoorioles.com>2022-06-15 17:55:42 +0300
committerHenrik Gramner <gramner@twoorioles.com>2022-06-21 00:11:13 +0300
commitfa68b036b25f7a5a30833de924b7a27e149699eb (patch)
tree65d7dea5aa7cb0eb319259f43deeea94d1d9211d /tests
parent0c590fc74d248541df3c0ad47683f642a36e465a (diff)
checkasm: Improve seed generation on Windows
GetTickCount() increases at a very low frequency, >10ms per tick. When running multiple loops of checkasm instances in parallel different instances regularly ends up using identical seeds. Prefer the use of QueryPerformanceCounter() instead, which ticks at a significantly higher rate, which in turn increases randomness.
Diffstat (limited to 'tests')
-rw-r--r--tests/checkasm/checkasm.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index e0aebaf..787ecbf 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -38,10 +38,6 @@
#define COLOR_RED FOREGROUND_RED
#define COLOR_GREEN FOREGROUND_GREEN
#define COLOR_YELLOW (FOREGROUND_RED|FOREGROUND_GREEN)
-
-static unsigned get_seed(void) {
- return GetTickCount();
-}
#else
#include <unistd.h>
#include <signal.h>
@@ -52,16 +48,6 @@ static unsigned get_seed(void) {
#define COLOR_RED 1
#define COLOR_GREEN 2
#define COLOR_YELLOW 3
-
-static unsigned get_seed(void) {
-#ifdef __APPLE__
- return (unsigned) mach_absolute_time();
-#elif defined(HAVE_CLOCK_GETTIME)
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return (unsigned) (1000000000ULL * ts.tv_sec + ts.tv_nsec);
-#endif
-}
#endif
/* List of tests to invoke */
@@ -521,6 +507,20 @@ static void print_cpu_name(void) {
}
}
+static unsigned get_seed(void) {
+#ifdef _WIN32
+ LARGE_INTEGER i;
+ QueryPerformanceCounter(&i);
+ return i.LowPart;
+#elif defined(__APPLE__)
+ return (unsigned) mach_absolute_time();
+#else
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (unsigned) (1000000000ULL * ts.tv_sec + ts.tv_nsec);
+#endif
+}
+
int main(int argc, char *argv[]) {
state.seed = get_seed();