mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
simplify BMK_syntheticTest()
This commit is contained in:
@ -697,9 +697,9 @@ static BMK_benchOutcome_t BMK_benchCLevel(const void* srcBuffer, size_t benchedS
|
|||||||
displayLevel, displayName, adv);
|
displayLevel, displayName, adv);
|
||||||
}
|
}
|
||||||
|
|
||||||
BMK_benchOutcome_t BMK_syntheticTest(int cLevel, double compressibility,
|
int BMK_syntheticTest(int cLevel, double compressibility,
|
||||||
const ZSTD_compressionParameters* compressionParams,
|
const ZSTD_compressionParameters* compressionParams,
|
||||||
int displayLevel, const BMK_advancedParams_t* adv)
|
int displayLevel, const BMK_advancedParams_t* adv)
|
||||||
{
|
{
|
||||||
char name[20] = {0};
|
char name[20] = {0};
|
||||||
size_t const benchedSize = 10000000;
|
size_t const benchedSize = 10000000;
|
||||||
@ -707,12 +707,16 @@ BMK_benchOutcome_t BMK_syntheticTest(int cLevel, double compressibility,
|
|||||||
BMK_benchOutcome_t res;
|
BMK_benchOutcome_t res;
|
||||||
|
|
||||||
if (cLevel > ZSTD_maxCLevel()) {
|
if (cLevel > ZSTD_maxCLevel()) {
|
||||||
RETURN_ERROR(15, BMK_benchOutcome_t, "Invalid Compression Level");
|
DISPLAYLEVEL(1, "Invalid Compression Level");
|
||||||
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Memory allocation */
|
/* Memory allocation */
|
||||||
srcBuffer = malloc(benchedSize);
|
srcBuffer = malloc(benchedSize);
|
||||||
if (!srcBuffer) RETURN_ERROR(21, BMK_benchOutcome_t, "not enough memory");
|
if (!srcBuffer) {
|
||||||
|
DISPLAYLEVEL(1, "allocation error : not enough memory");
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
/* Fill input buffer */
|
/* Fill input buffer */
|
||||||
RDG_genBuffer(srcBuffer, benchedSize, compressibility, 0.0, 0);
|
RDG_genBuffer(srcBuffer, benchedSize, compressibility, 0.0, 0);
|
||||||
@ -728,7 +732,7 @@ BMK_benchOutcome_t BMK_syntheticTest(int cLevel, double compressibility,
|
|||||||
/* clean up */
|
/* clean up */
|
||||||
free(srcBuffer);
|
free(srcBuffer);
|
||||||
|
|
||||||
return res;
|
return !BMK_isSuccessful_benchOutcome(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,11 +91,11 @@ BMK_benchResult_t BMK_extract_benchResult(BMK_benchOutcome_t outcome);
|
|||||||
* .cSize : compressed size, in bytes
|
* .cSize : compressed size, in bytes
|
||||||
* .cMem : memory budget required for the compression context
|
* .cMem : memory budget required for the compression context
|
||||||
*/
|
*/
|
||||||
BMK_benchOutcome_t BMK_benchFiles(
|
BMK_benchOutcome_t
|
||||||
const char* const * fileNamesTable, unsigned nbFiles,
|
BMK_benchFiles( const char* const * fileNamesTable, unsigned nbFiles,
|
||||||
const char* dictFileName,
|
const char* dictFileName,
|
||||||
int cLevel, const ZSTD_compressionParameters* compressionParams,
|
int cLevel, const ZSTD_compressionParameters* compressionParams,
|
||||||
int displayLevel);
|
int displayLevel);
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -126,11 +126,12 @@ BMK_advancedParams_t BMK_initAdvancedParams(void);
|
|||||||
/*! BMK_benchFilesAdvanced():
|
/*! BMK_benchFilesAdvanced():
|
||||||
* Same as BMK_benchFiles(),
|
* Same as BMK_benchFiles(),
|
||||||
* with more controls, provided through advancedParams_t structure */
|
* with more controls, provided through advancedParams_t structure */
|
||||||
BMK_benchOutcome_t BMK_benchFilesAdvanced(
|
BMK_benchOutcome_t
|
||||||
const char* const * fileNamesTable, unsigned nbFiles,
|
BMK_benchFilesAdvanced(
|
||||||
const char* dictFileName,
|
const char* const * fileNamesTable, unsigned nbFiles,
|
||||||
int cLevel, const ZSTD_compressionParameters* compressionParams,
|
const char* dictFileName,
|
||||||
int displayLevel, const BMK_advancedParams_t* adv);
|
int cLevel, const ZSTD_compressionParameters* compressionParams,
|
||||||
|
int displayLevel, const BMK_advancedParams_t* adv);
|
||||||
|
|
||||||
/*! BMK_syntheticTest() -- called from zstdcli */
|
/*! BMK_syntheticTest() -- called from zstdcli */
|
||||||
/* Generates a sample with datagen, using compressibility argument */
|
/* Generates a sample with datagen, using compressibility argument */
|
||||||
@ -139,20 +140,11 @@ BMK_benchOutcome_t BMK_benchFilesAdvanced(
|
|||||||
* compressionParams - basic compression Parameters
|
* compressionParams - basic compression Parameters
|
||||||
* displayLevel - see benchFiles
|
* displayLevel - see benchFiles
|
||||||
* adv - see advanced_Params_t
|
* adv - see advanced_Params_t
|
||||||
* @return:
|
* @return: 0 on success, !0 on error
|
||||||
* a variant, which expresses either an error, or a valid result.
|
|
||||||
* Use BMK_isSuccessful_benchOutcome() to check if function was successful.
|
|
||||||
* If yes, extract the valid result with BMK_extract_benchResult(),
|
|
||||||
* it will contain :
|
|
||||||
* .cSpeed: compression speed in bytes per second,
|
|
||||||
* .dSpeed: decompression speed in bytes per second,
|
|
||||||
* .cSize : compressed size, in bytes
|
|
||||||
* .cMem : memory budget required for the compression context
|
|
||||||
*/
|
*/
|
||||||
BMK_benchOutcome_t BMK_syntheticTest(
|
int BMK_syntheticTest(int cLevel, double compressibility,
|
||||||
int cLevel, double compressibility,
|
const ZSTD_compressionParameters* compressionParams,
|
||||||
const ZSTD_compressionParameters* compressionParams,
|
int displayLevel, const BMK_advancedParams_t* adv);
|
||||||
int displayLevel, const BMK_advancedParams_t* adv);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -190,8 +182,8 @@ BMK_benchOutcome_t BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
int displayLevel, const char* displayName);
|
int displayLevel, const char* displayName);
|
||||||
|
|
||||||
|
|
||||||
/* BMK_benchMemAdvanced() : same as BMK_benchMem()
|
/* BMK_benchMemAdvanced() : used by Paramgrill
|
||||||
* with following additional options :
|
* same as BMK_benchMem() with following additional options :
|
||||||
* dstBuffer - destination buffer to write compressed output in, NULL if none provided.
|
* dstBuffer - destination buffer to write compressed output in, NULL if none provided.
|
||||||
* dstCapacity - capacity of destination buffer, give 0 if dstBuffer = NULL
|
* dstCapacity - capacity of destination buffer, give 0 if dstBuffer = NULL
|
||||||
* adv = see advancedParams_t
|
* adv = see advancedParams_t
|
||||||
|
@ -1401,8 +1401,8 @@ int main(int argCount, const char* argv[])
|
|||||||
} }
|
} }
|
||||||
} else {
|
} else {
|
||||||
for(; cLevel <= cLevelLast; cLevel++) {
|
for(; cLevel <= cLevelLast; cLevel++) {
|
||||||
BMK_benchOutcome_t const bo = BMK_syntheticTest(cLevel, compressibility, &compressionParams, g_displayLevel, &benchParams);
|
if ( BMK_syntheticTest(cLevel, compressibility, &compressionParams, g_displayLevel, &benchParams) )
|
||||||
if (!BMK_isSuccessful_benchOutcome(bo)) return 1;
|
return 1;
|
||||||
} }
|
} }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user