mirror of
https://github.com/facebook/zstd.git
synced 2025-03-07 01:10:04 +02:00
added more accurate error messages
for the decompression-only benchmark mode.
This commit is contained in:
parent
9cabd155fd
commit
58e7067c7d
@ -327,26 +327,31 @@ BMK_benchMemAdvancedNoAlloc(
|
|||||||
/* init */
|
/* init */
|
||||||
memset(&benchResult, 0, sizeof(benchResult));
|
memset(&benchResult, 0, sizeof(benchResult));
|
||||||
if (strlen(displayName)>17) displayName += strlen(displayName) - 17; /* display last 17 characters */
|
if (strlen(displayName)>17) displayName += strlen(displayName) - 17; /* display last 17 characters */
|
||||||
if (adv->mode == BMK_decodeOnly) { /* benchmark only decompression : source must be already compressed */
|
if (adv->mode == BMK_decodeOnly) {
|
||||||
|
/* benchmark only decompression : source must be already compressed */
|
||||||
const char* srcPtr = (const char*)srcBuffer;
|
const char* srcPtr = (const char*)srcBuffer;
|
||||||
U64 totalDSize64 = 0;
|
U64 totalDSize64 = 0;
|
||||||
U32 fileNb;
|
U32 fileNb;
|
||||||
for (fileNb=0; fileNb<nbFiles; fileNb++) {
|
for (fileNb=0; fileNb<nbFiles; fileNb++) {
|
||||||
U64 const fSize64 = ZSTD_findDecompressedSize(srcPtr, fileSizes[fileNb]);
|
U64 const fSize64 = ZSTD_findDecompressedSize(srcPtr, fileSizes[fileNb]);
|
||||||
if (fSize64==0) RETURN_ERROR(32, BMK_benchOutcome_t, "Impossible to determine original size ");
|
if (fSize64 == ZSTD_CONTENTSIZE_UNKNOWN) {
|
||||||
|
RETURN_ERROR(32, BMK_benchOutcome_t, "Decompressed size cannot be determined: cannot benchmark");
|
||||||
|
}
|
||||||
|
if (fSize64 == ZSTD_CONTENTSIZE_ERROR) {
|
||||||
|
RETURN_ERROR(32, BMK_benchOutcome_t, "Error while trying to assess decompressed size: data may be invalid");
|
||||||
|
}
|
||||||
totalDSize64 += fSize64;
|
totalDSize64 += fSize64;
|
||||||
srcPtr += fileSizes[fileNb];
|
srcPtr += fileSizes[fileNb];
|
||||||
}
|
}
|
||||||
{ size_t const decodedSize = (size_t)totalDSize64;
|
{ size_t const decodedSize = (size_t)totalDSize64;
|
||||||
assert((U64)decodedSize == totalDSize64); /* check overflow */
|
assert((U64)decodedSize == totalDSize64); /* check overflow */
|
||||||
free(*resultBufferPtr);
|
free(*resultBufferPtr);
|
||||||
|
if (totalDSize64 > decodedSize) { /* size_t overflow */
|
||||||
|
RETURN_ERROR(32, BMK_benchOutcome_t, "decompressed size is too large for local system");
|
||||||
|
}
|
||||||
*resultBufferPtr = malloc(decodedSize);
|
*resultBufferPtr = malloc(decodedSize);
|
||||||
if (!(*resultBufferPtr)) {
|
if (!(*resultBufferPtr)) {
|
||||||
RETURN_ERROR(33, BMK_benchOutcome_t, "not enough memory");
|
RETURN_ERROR(33, BMK_benchOutcome_t, "allocation error: not enough memory");
|
||||||
}
|
|
||||||
if (totalDSize64 > decodedSize) { /* size_t overflow */
|
|
||||||
free(*resultBufferPtr);
|
|
||||||
RETURN_ERROR(32, BMK_benchOutcome_t, "original size is too large");
|
|
||||||
}
|
}
|
||||||
cSize = srcSize;
|
cSize = srcSize;
|
||||||
srcSize = decodedSize;
|
srcSize = decodedSize;
|
||||||
@ -474,7 +479,7 @@ BMK_benchMemAdvancedNoAlloc(
|
|||||||
BMK_runOutcome_t const dOutcome = BMK_benchTimedFn(timeStateDecompress, dbp);
|
BMK_runOutcome_t const dOutcome = BMK_benchTimedFn(timeStateDecompress, dbp);
|
||||||
|
|
||||||
if(!BMK_isSuccessful_runOutcome(dOutcome)) {
|
if(!BMK_isSuccessful_runOutcome(dOutcome)) {
|
||||||
return BMK_benchOutcome_error();
|
RETURN_ERROR(30, BMK_benchOutcome_t, "decompression error");
|
||||||
}
|
}
|
||||||
|
|
||||||
{ BMK_runTime_t const dResult = BMK_extract_runTime(dOutcome);
|
{ BMK_runTime_t const dResult = BMK_extract_runTime(dOutcome);
|
||||||
@ -598,7 +603,7 @@ BMK_benchOutcome_t BMK_benchMemAdvanced(const void* srcBuffer, size_t srcSize,
|
|||||||
|
|
||||||
void* resultBuffer = srcSize ? malloc(srcSize) : NULL;
|
void* resultBuffer = srcSize ? malloc(srcSize) : NULL;
|
||||||
|
|
||||||
int allocationincomplete = !srcPtrs || !srcSizes || !cPtrs ||
|
int const allocationincomplete = !srcPtrs || !srcSizes || !cPtrs ||
|
||||||
!cSizes || !cCapacities || !resPtrs || !resSizes ||
|
!cSizes || !cCapacities || !resPtrs || !resSizes ||
|
||||||
!timeStateCompress || !timeStateDecompress ||
|
!timeStateCompress || !timeStateDecompress ||
|
||||||
!cctx || !dctx ||
|
!cctx || !dctx ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user