diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2014-11-27 21:44:36 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2014-11-27 21:44:36 (GMT) |
commit | 2d98faf238516ecd6588f9202f8ae546c0b798e4 (patch) | |
tree | 4bf127ce81d001a0c3cd2cfe4b8cd14b5a0f563d /programs | |
parent | 86fa21b3019d7e9983704661966a64f5aa1456bf (diff) | |
download | lz4-2d98faf238516ecd6588f9202f8ae546c0b798e4.zip lz4-2d98faf238516ecd6588f9202f8ae546c0b798e4.tar.gz lz4-2d98faf238516ecd6588f9202f8ae546c0b798e4.tar.bz2 |
Improved decoding speed
Diffstat (limited to 'programs')
-rw-r--r-- | programs/fullbench.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/programs/fullbench.c b/programs/fullbench.c index cdf1d1d..647a458 100644 --- a/programs/fullbench.c +++ b/programs/fullbench.c @@ -454,7 +454,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles) // Alloc chunkP = (struct chunkParameters*) malloc(((benchedSize / (size_t)chunkSize)+1) * sizeof(struct chunkParameters)); orig_buff = (char*) malloc((size_t)benchedSize); - nbChunks = (int) ((int)benchedSize / chunkSize) + 1; + nbChunks = (int) (((int)benchedSize + (chunkSize-1))/ chunkSize); maxCompressedChunkSize = LZ4_compressBound(chunkSize); compressedBuffSize = nbChunks * maxCompressedChunkSize; compressed_buff = (char*)malloc((size_t)compressedBuffSize); @@ -511,7 +511,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles) size_t remaining = benchedSize; char* in = orig_buff; char* out = compressed_buff; - nbChunks = (int) ((int)benchedSize / chunkSize) + 1; + nbChunks = (int) (((int)benchedSize + (chunkSize-1))/ chunkSize); for (i=0; i<nbChunks; i++) { chunkP[i].id = i; @@ -593,6 +593,22 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles) } // Prepare layout for decompression + // Init data chunks + { + int i; + size_t remaining = benchedSize; + char* in = orig_buff; + char* out = compressed_buff; + nbChunks = (int) (((int)benchedSize + (chunkSize-1))/ chunkSize); + for (i=0; i<nbChunks; i++) + { + chunkP[i].id = i; + chunkP[i].origBuffer = in; in += chunkSize; + if ((int)remaining > chunkSize) { chunkP[i].origSize = chunkSize; remaining -= chunkSize; } else { chunkP[i].origSize = (int)remaining; remaining = 0; } + chunkP[i].compressedBuffer = out; out += maxCompressedChunkSize; + chunkP[i].compressedSize = 0; + } + } for (chunkNb=0; chunkNb<nbChunks; chunkNb++) { chunkP[chunkNb].compressedSize = LZ4_compress(chunkP[chunkNb].origBuffer, chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origSize); |