int BMK_isSuccessful_runOutcome(BMK_runOutcome_t outcome)
{
- return outcome.tag == 0;
+ return outcome.tag < 2;
}
/* warning : this function will stop program execution if outcome is invalid !
* check outcome validity first, using BMK_isValid_runResult() */
BMK_runTime_t BMK_extract_runTime(BMK_runOutcome_t outcome)
{
- assert(outcome.tag == 0);
+ assert(outcome.tag < 2);
return outcome.internal_never_use_directly;
}
size_t dstSize = 0;
if(!nbLoops) {
- RETURN_QUIET_ERROR(1, BMK_runOutcome_t, "nbLoops must be nonzero ");
+ RETURN_QUIET_ERROR(2, BMK_runOutcome_t, "nbLoops must be nonzero ");
}
/* init */
}
-/* check first if the return structure represents an error or a valid result */
-int BMK_isSuccessful_timedFnOutcome(BMK_timedFnOutcome_t outcome)
-{
- return (outcome.tag < 2);
-}
-
-/* extract intermediate results from variant type.
- * note : this function will abort() program execution if result is not valid.
- * check result validity first, by using BMK_isSuccessful_timedFnOutcome() */
-BMK_runTime_t BMK_extract_timedFnResult(BMK_timedFnOutcome_t outcome)
-{
- assert(outcome.tag < 2);
- return outcome.internal_never_use_directly;
-}
-
/* Tells if nb of seconds set in timedFnState for all runs is spent.
* note : this function will return 1 if BMK_benchFunctionTimed() has actually errored. */
-int BMK_isCompleted_timedFnOutcome(BMK_timedFnOutcome_t outcome)
+int BMK_isCompleted_runOutcome(BMK_runOutcome_t outcome)
{
return (outcome.tag >= 1);
}
#define MINUSABLETIME (TIMELOOP_NANOSEC / 2) /* 0.5 seconds */
-BMK_timedFnOutcome_t BMK_benchFunctionTimed(
+BMK_runOutcome_t BMK_benchFunctionTimed(
BMK_timedFnState_t* cont,
BMK_benchFn_t benchFn, void* benchPayload,
BMK_initFn_t initFn, void* initPayload,
size_t* blockResults)
{
int completed = 0;
- BMK_timedFnOutcome_t r;
+ BMK_runOutcome_t r;
BMK_runTime_t bestRunTime = cont->fastestRun;
r.tag = 2; /* error by default */
while (!(compressionCompleted && decompressionCompleted)) {
if (!compressionCompleted) {
- BMK_timedFnOutcome_t const cOutcome =
+ BMK_runOutcome_t const cOutcome =
BMK_benchFunctionTimed( timeStateCompress,
&local_defaultCompress, cctx,
&local_initCCtx, &cctxprep,
cPtrs, cCapacities,
cSizes);
- if (!BMK_isSuccessful_timedFnOutcome(cOutcome)) {
+ if (!BMK_isSuccessful_runOutcome(cOutcome)) {
return BMK_benchOutcome_error();
}
- { BMK_runTime_t const cResult = BMK_extract_timedFnResult(cOutcome);
+ { BMK_runTime_t const cResult = BMK_extract_runTime(cOutcome);
cSize = cResult.sumOfReturn;
ratio = (double)srcSize / cSize;
{ BMK_benchResult_t newResult;
ratioAccuracy, ratio,
benchResult.cSpeed < (10 MB) ? 2 : 1, (double)benchResult.cSpeed / MB_UNIT);
}
- compressionCompleted = BMK_isCompleted_timedFnOutcome(cOutcome);
+ compressionCompleted = BMK_isCompleted_runOutcome(cOutcome);
}
if(!decompressionCompleted) {
- BMK_timedFnOutcome_t const dOutcome =
+ BMK_runOutcome_t const dOutcome =
BMK_benchFunctionTimed(timeStateDecompress,
&local_defaultDecompress, dctx,
&local_initDCtx, &dctxprep,
resPtrs, resSizes,
NULL);
- if(!BMK_isSuccessful_timedFnOutcome(dOutcome)) {
+ if(!BMK_isSuccessful_runOutcome(dOutcome)) {
return BMK_benchOutcome_error();
}
- { BMK_runTime_t const dResult = BMK_extract_timedFnResult(dOutcome);
+ { BMK_runTime_t const dResult = BMK_extract_runTime(dOutcome);
U64 const newDSpeed = (srcSize * TIMELOOP_NANOSEC / dResult.nanoSecPerRun);
if (newDSpeed > benchResult.dSpeed)
benchResult.dSpeed = newDSpeed;
benchResult.cSpeed < (10 MB) ? 2 : 1, (double)benchResult.cSpeed / MB_UNIT,
(double)benchResult.dSpeed / MB_UNIT);
}
- decompressionCompleted = BMK_isCompleted_timedFnOutcome(dOutcome);
+ decompressionCompleted = BMK_isCompleted_runOutcome(dOutcome);
}
} /* while (!(compressionCompleted && decompressionCompleted)) */
BMK_runTime_t BMK_extract_runTime(BMK_runOutcome_t outcome);
+
typedef size_t (*BMK_benchFn_t)(const void* src, size_t srcSize, void* dst, size_t dstCapacity, void* customPayload);
typedef size_t (*BMK_initFn_t)(void* initPayload);
void BMK_resetTimedFnState(BMK_timedFnState_t* timedFnState, unsigned nbSeconds);
void BMK_freeTimedFnState(BMK_timedFnState_t* state);
-/* define timedFnOutcome */
-VARIANT_ERROR_RESULT(BMK_runTime_t, BMK_timedFnOutcome_t);
-
-/* check first if the return structure represents an error or a valid result */
-int BMK_isSuccessful_timedFnOutcome(BMK_timedFnOutcome_t outcome);
-
-/* extract intermediate results from variant type.
- * note : this function will abort() program execution if result is not valid.
- * check result validity first, by using BMK_isSuccessful_timedFnOutcome() */
-BMK_runTime_t BMK_extract_timedFnResult(BMK_timedFnOutcome_t outcome);
-
-/* Tells if nb of seconds set in timedFnState for all runs is spent.
- * note : this function will return 1 if BMK_benchFunctionTimed() has actually errored. */
-int BMK_isCompleted_timedFnOutcome(BMK_timedFnOutcome_t outcome);
-
/* BMK_benchFunctionTimed() :
* Similar to BMK_benchFunction(),
* Most arguments are the same as BMK_benchFunction()
* Usage - initialize a timedFnState, selecting a total nbSeconds allocated for _all_ benchmarks run
* call BMK_benchFunctionTimed() repetitively, collecting intermediate results (each run is supposed to last about 1 seconds)
- * Check if time budget is spent using BMK_isCompleted_timedFnOutcome()
+ * Check if time budget is spent using BMK_isCompleted_runOutcome()
*/
-BMK_timedFnOutcome_t BMK_benchFunctionTimed(
- BMK_timedFnState_t* timedFnState,
- BMK_benchFn_t benchFn, void* benchPayload,
- BMK_initFn_t initFn, void* initPayload,
- size_t blockCount,
- const void *const * srcBlockBuffers, const size_t* srcBlockSizes,
- void *const * dstBlockBuffers, const size_t* dstBlockCapacities,
- size_t* blockResults);
+BMK_runOutcome_t BMK_benchFunctionTimed(
+ BMK_timedFnState_t* timedFnState,
+ BMK_benchFn_t benchFn, void* benchPayload,
+ BMK_initFn_t initFn, void* initPayload,
+ size_t blockCount,
+ const void *const * srcBlockBuffers, const size_t* srcBlockSizes,
+ void *const * dstBlockBuffers, const size_t* dstBlockCapacities,
+ size_t* blockResults);
+
+
+/* Tells if total nb of benchmark runs has exceeded amount of time set in timedFnState
+ */
+int BMK_isCompleted_runOutcome(BMK_runOutcome_t outcome);
+
+
#endif /* BENCH_H_121279284357 */
bestResult.nanoSecPerRun = (unsigned long long)(-1LL);
for (;;) {
void* const dstBuffv = dstBuff;
- BMK_timedFnOutcome_t const bOutcome =
+ BMK_runOutcome_t const bOutcome =
BMK_benchFunctionTimed( tfs,
benchFunction, buff2,
NULL, NULL, /* initFn */
&dstBuffv, &dstBuffSize,
NULL);
- if (!BMK_isSuccessful_timedFnOutcome(bOutcome)) {
+ if (!BMK_isSuccessful_runOutcome(bOutcome)) {
DISPLAY("ERROR benchmarking function ! ! \n");
errorcode = 1;
goto _cleanOut;
}
- { BMK_runTime_t const newResult = BMK_extract_timedFnResult(bOutcome);
+ { BMK_runTime_t const newResult = BMK_extract_runTime(bOutcome);
if (newResult.nanoSecPerRun < bestResult.nanoSecPerRun )
bestResult.nanoSecPerRun = newResult.nanoSecPerRun;
DISPLAY("\r%2u#%-29.29s:%8.1f MB/s (%8u) ",
(unsigned)newResult.sumOfReturn );
}
- if ( BMK_isCompleted_timedFnOutcome(bOutcome) ) break;
+ if ( BMK_isCompleted_runOutcome(bOutcome) ) break;
} }
DISPLAY("\n");
dctxprep.dictBufferSize = dictBufferSize;
while(!compressionCompleted) {
- BMK_timedFnOutcome_t const cOutcome = BMK_benchFunctionTimed(timeStateCompress,
+ BMK_runOutcome_t const cOutcome = BMK_benchFunctionTimed(timeStateCompress,
&local_defaultCompress, cctx,
&local_initCCtx, &cctxprep,
nbBlocks,
dstPtrs, dstCapacities,
dstSizes);
- if (!BMK_isSuccessful_timedFnOutcome(cOutcome)) {
+ if (!BMK_isSuccessful_runOutcome(cOutcome)) {
BMK_benchOutcome_t bOut;
bOut.tag = 1; /* should rather be a function or a constant */
BMK_freeTimedFnState(timeStateCompress);
BMK_freeTimedFnState(timeStateDecompress);
return bOut;
}
- { BMK_runTime_t const rResult = BMK_extract_timedFnResult(cOutcome);
+ { BMK_runTime_t const rResult = BMK_extract_runTime(cOutcome);
bResult.cSpeed = (srcSize * TIMELOOP_NANOSEC) / rResult.nanoSecPerRun;
bResult.cSize = rResult.sumOfReturn;
}
- compressionCompleted = BMK_isCompleted_timedFnOutcome(cOutcome);
+ compressionCompleted = BMK_isCompleted_runOutcome(cOutcome);
}
while (!decompressionCompleted) {
- BMK_timedFnOutcome_t const dOutcome = BMK_benchFunctionTimed(timeStateDecompress,
+ BMK_runOutcome_t const dOutcome = BMK_benchFunctionTimed(timeStateDecompress,
&local_defaultDecompress, dctx,
&local_initDCtx, &dctxprep,
nbBlocks,
resPtrs, resSizes,
NULL);
- if (!BMK_isSuccessful_timedFnOutcome(dOutcome)) {
+ if (!BMK_isSuccessful_runOutcome(dOutcome)) {
BMK_benchOutcome_t bOut;
bOut.tag = 1; /* should rather be a function or a constant */
BMK_freeTimedFnState(timeStateCompress);
BMK_freeTimedFnState(timeStateDecompress);
return bOut;
}
- { BMK_runTime_t const rResult = BMK_extract_timedFnResult(dOutcome);
+ { BMK_runTime_t const rResult = BMK_extract_runTime(dOutcome);
bResult.dSpeed = (srcSize * TIMELOOP_NANOSEC) / rResult.nanoSecPerRun;
}
- decompressionCompleted = BMK_isCompleted_timedFnOutcome(dOutcome);
+ decompressionCompleted = BMK_isCompleted_runOutcome(dOutcome);
}
BMK_freeTimedFnState(timeStateCompress);