better seed randomization for systems with poor clock() resolutation

This commit is contained in:
Yann Collet 2016-06-16 13:38:10 +02:00
parent 23ba41533a
commit 3f01c8833f

View File

@ -847,7 +847,12 @@ int main(int argc, const char** argv)
/* Get Seed */
DISPLAY("Starting zstd tester (%i-bits, %s)\n", (int)(sizeof(size_t)*8), ZSTD_VERSION_STRING);
if (!seedset) seed = (U32)(clock() % 10000);
if (!seedset) {
time_t const t = time(NULL);
U32 const h = XXH32(&t, sizeof(t), 1);
seed = h % 10000;
}
DISPLAY("Seed = %u\n", seed);
if (proba!=FUZ_compressibility_default) DISPLAY("Compressibility : %u%%\n", proba);