mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
zwrapbench: testing speed of ZSTD_decompressStream
This commit is contained in:
2
zlibWrapper/.gitignore
vendored
2
zlibWrapper/.gitignore
vendored
@ -26,4 +26,4 @@ foo.gz
|
|||||||
# Misc files
|
# Misc files
|
||||||
*.bat
|
*.bat
|
||||||
*.zip
|
*.zip
|
||||||
examples/example2.c
|
*.txt
|
||||||
|
@ -41,7 +41,7 @@ test_zstd: example_zstd fitblk_zstd zwrapbench
|
|||||||
./example_zstd
|
./example_zstd
|
||||||
./fitblk_zstd 10240 <../zstd_compression_format.md
|
./fitblk_zstd 10240 <../zstd_compression_format.md
|
||||||
./fitblk_zstd 40960 <../zstd_compression_format.md
|
./fitblk_zstd 40960 <../zstd_compression_format.md
|
||||||
./zwrapbench ../zstd_compression_format.md
|
./zwrapbench -qb1e5 ../zstd_compression_format.md
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
@ -281,9 +281,9 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
if (compressor == BMK_ZLIB || compressor == BMK_ZWRAP_ZLIB) useZSTDcompression(0);
|
if (compressor == BMK_ZLIB || compressor == BMK_ZWRAP_ZLIB) useZSTDcompression(0);
|
||||||
else useZSTDcompression(1);
|
else useZSTDcompression(1);
|
||||||
do {
|
do {
|
||||||
|
z_stream def;
|
||||||
U32 blockNb;
|
U32 blockNb;
|
||||||
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
|
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
|
||||||
z_stream def;
|
|
||||||
int ret;
|
int ret;
|
||||||
def.zalloc = Z_NULL;
|
def.zalloc = Z_NULL;
|
||||||
def.zfree = Z_NULL;
|
def.zfree = Z_NULL;
|
||||||
@ -334,7 +334,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
|
|
||||||
if (!dCompleted) {
|
if (!dCompleted) {
|
||||||
U32 nbLoops = 0;
|
U32 nbLoops = 0;
|
||||||
if (compressor == BMK_ZSTD || compressor == BMK_ZSTD2) {
|
if (compressor == BMK_ZSTD) {
|
||||||
ZSTD_DDict* ddict = ZSTD_createDDict(dictBuffer, dictBufferSize);
|
ZSTD_DDict* ddict = ZSTD_createDDict(dictBuffer, dictBufferSize);
|
||||||
if (!ddict) EXM_THROW(2, "ZSTD_createDDict() allocation failure");
|
if (!ddict) EXM_THROW(2, "ZSTD_createDDict() allocation failure");
|
||||||
do {
|
do {
|
||||||
@ -355,13 +355,38 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
nbLoops++;
|
nbLoops++;
|
||||||
} while (UTIL_clockSpanMicro(clockStart, ticksPerSecond) < clockLoop);
|
} while (UTIL_clockSpanMicro(clockStart, ticksPerSecond) < clockLoop);
|
||||||
ZSTD_freeDDict(ddict);
|
ZSTD_freeDDict(ddict);
|
||||||
|
} else if (compressor == BMK_ZSTD2) {
|
||||||
|
ZSTD_inBuffer inBuffer;
|
||||||
|
ZSTD_outBuffer outBuffer;
|
||||||
|
ZSTD_DStream* zbd = ZSTD_createDStream();
|
||||||
|
if (zbd == NULL) EXM_THROW(1, "ZSTD_createDStream() allocation failure");
|
||||||
|
|
||||||
|
do {
|
||||||
|
U32 blockNb;
|
||||||
|
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
|
||||||
|
size_t rSize;
|
||||||
|
rSize = ZSTD_initDStream(zbd);
|
||||||
|
if (ZSTD_isError(rSize)) EXM_THROW(1, "ZSTD_initDStream() failed : %s", ZSTD_getErrorName(rSize));
|
||||||
|
inBuffer.src = blockTable[blockNb].cPtr;
|
||||||
|
inBuffer.size = blockTable[blockNb].cSize;
|
||||||
|
inBuffer.pos = 0;
|
||||||
|
outBuffer.dst = blockTable[blockNb].resPtr;
|
||||||
|
outBuffer.size = blockTable[blockNb].srcSize;
|
||||||
|
outBuffer.pos = 0;
|
||||||
|
rSize = ZSTD_decompressStream(zbd, &outBuffer, &inBuffer);
|
||||||
|
if (ZSTD_isError(rSize)) EXM_THROW(1, "ZSTD_decompressStream() failed : %s", ZSTD_getErrorName(rSize));
|
||||||
|
blockTable[blockNb].resSize = outBuffer.pos;
|
||||||
|
}
|
||||||
|
nbLoops++;
|
||||||
|
} while (UTIL_clockSpanMicro(clockStart, ticksPerSecond) < clockLoop);
|
||||||
|
ZSTD_freeDStream(zbd);
|
||||||
} else {
|
} else {
|
||||||
if (compressor == BMK_ZLIB) setZWRAPdecompressionType(ZWRAP_FORCE_ZLIB);
|
if (compressor == BMK_ZLIB) setZWRAPdecompressionType(ZWRAP_FORCE_ZLIB);
|
||||||
else setZWRAPdecompressionType(ZWRAP_AUTO);
|
else setZWRAPdecompressionType(ZWRAP_AUTO);
|
||||||
do {
|
do {
|
||||||
U32 blockNb;
|
U32 blockNb;
|
||||||
|
z_stream inf;
|
||||||
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
|
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
|
||||||
z_stream inf;
|
|
||||||
int ret;
|
int ret;
|
||||||
inf.zalloc = Z_NULL;
|
inf.zalloc = Z_NULL;
|
||||||
inf.zfree = Z_NULL;
|
inf.zfree = Z_NULL;
|
||||||
|
Reference in New Issue
Block a user