paramgrill: fixed a bunch of div-by-zero

they were pretty easy to trigger by the way,
just start an extended paramgrill session
to find a compression table based on any sample,
it would necessarily happen at some point.
This commit is contained in:
Yann Collet
2018-08-27 18:47:09 -07:00
parent 0071e8348f
commit 9e26893e07
+10 -3
View File
@@ -468,7 +468,7 @@ static void paramVariation(paramValues_t* ptr, memoTable_t* mtAll, const U32 nbC
static paramValues_t randomParams(void) static paramValues_t randomParams(void)
{ {
varInds_t v; paramValues_t p; varInds_t v; paramValues_t p;
for(v = 0; v <= NUM_PARAMS; v++) { for(v = 0; v < NUM_PARAMS; v++) {
p.vals[v] = rangeMap(v, FUZ_rand(&g_rand) % rangetable[v]); p.vals[v] = rangeMap(v, FUZ_rand(&g_rand) % rangetable[v]);
} }
return p; return p;
@@ -644,7 +644,8 @@ static void BMK_translateAdvancedParams(FILE* f, const paramValues_t params) {
fprintf(f, "\n"); fprintf(f, "\n");
} }
static void BMK_displayOneResult(FILE* f, winnerInfo_t res, const size_t srcSize) { static void BMK_displayOneResult(FILE* f, winnerInfo_t res, const size_t srcSize)
{
varInds_t v; varInds_t v;
int first = 1; int first = 1;
res.params = cParamUnsetMin(res.params); res.params = cParamUnsetMin(res.params);
@@ -656,8 +657,14 @@ static void BMK_displayOneResult(FILE* f, winnerInfo_t res, const size_t srcSize
first = 0; first = 0;
} }
{ double const ratio = res.result.cSize ?
(double)srcSize / res.result.cSize : 0;
double const cSpeedMBps = (double)res.result.cSpeed / MB_UNIT;
double const dSpeedMBps = (double)res.result.dSpeed / MB_UNIT;
fprintf(f, " }, /* R:%5.3f at %5.1f MB/s - %5.1f MB/s */\n", fprintf(f, " }, /* R:%5.3f at %5.1f MB/s - %5.1f MB/s */\n",
(double)srcSize / res.result.cSize, (double)res.result.cSpeed / MB_UNIT, (double)res.result.dSpeed / MB_UNIT); ratio, cSpeedMBps, dSpeedMBps);
}
} }
/* Writes to f the results of a parameter benchmark */ /* Writes to f the results of a parameter benchmark */