mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Be able to test and bench the miniz library
For the record, benchstat numbers for 'old' being zlib-the-library and 'new' being miniz are below. Neither 'old' or 'new' is Wuffs code. name old speed new speed delta mimic_deflate_decode_1k/clang 217MB/s ± 1% 175MB/s ± 1% -19.54% (p=0.008 n=5+5) mimic_deflate_decode_10k/clang 262MB/s ± 2% 222MB/s ± 0% -15.34% (p=0.008 n=5+5) mimic_deflate_decode_100k/clang 281MB/s ± 1% 262MB/s ± 0% -6.86% (p=0.008 n=5+5) mimic_deflate_decode_1k/gcc 220MB/s ± 1% 169MB/s ± 0% -23.12% (p=0.008 n=5+5) mimic_deflate_decode_10k/gcc 267MB/s ± 0% 266MB/s ± 0% ~ (p=0.222 n=5+5) mimic_deflate_decode_100k/gcc 283MB/s ± 0% 282MB/s ± 1% ~ (p=0.690 n=5+5) mimic_zlib_decode_10k/clang 243MB/s ± 1% 197MB/s ± 1% -18.68% (p=0.008 n=5+5) mimic_zlib_decode_100k/clang 287MB/s ± 1% 229MB/s ± 1% -20.13% (p=0.008 n=5+5) mimic_zlib_decode_10k/gcc 243MB/s ± 0% 240MB/s ± 6% ~ (p=0.730 n=5+5) mimic_zlib_decode_100k/gcc 288MB/s ± 1% 260MB/s ± 0% -9.51% (p=0.008 n=5+5)
This commit is contained in:
1 parent
3b822f8b17
commit
4877279ee7
2 files changed
+68
-1
No files matched your search
@@ -12,6 +12,69 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Uncomment this line to test and bench miniz instead of zlib-the-library.
|
||||
// #define WUFFS_MIMICLIB_USE_MINIZ_INSTEAD_OF_ZLIB 1
|
||||
|
||||
#ifdef WUFFS_MIMICLIB_USE_MINIZ_INSTEAD_OF_ZLIB
|
||||
#include "/path/to/your/copy/of/github.com/richgel999/miniz/miniz_tinfl.c"
|
||||
|
||||
const char* mimic_bench_adler32(wuffs_base__buf1* dst,
|
||||
wuffs_base__buf1* src,
|
||||
uint64_t wlimit,
|
||||
uint64_t rlimit) {
|
||||
return "miniz does not independently compute Adler32";
|
||||
}
|
||||
|
||||
const char* mimic_bench_crc32(wuffs_base__buf1* dst,
|
||||
wuffs_base__buf1* src,
|
||||
uint64_t wlimit,
|
||||
uint64_t rlimit) {
|
||||
return "miniz does not implement CRC32";
|
||||
}
|
||||
|
||||
const char* mimic_deflate_zlib_decode(wuffs_base__buf1* dst,
|
||||
wuffs_base__buf1* src,
|
||||
uint64_t wlimit,
|
||||
uint64_t rlimit,
|
||||
bool deflate_instead_of_zlib) {
|
||||
// TODO: don't ignore wlimit and rlimit.
|
||||
int flags = 0;
|
||||
if (!deflate_instead_of_zlib) {
|
||||
flags |= TINFL_FLAG_PARSE_ZLIB_HEADER;
|
||||
}
|
||||
size_t n =
|
||||
tinfl_decompress_mem_to_mem(dst->ptr + dst->wi, dst->len - dst->wi,
|
||||
src->ptr + src->ri, src->wi - src->ri, flags);
|
||||
if (n == TINFL_DECOMPRESS_MEM_TO_MEM_FAILED) {
|
||||
return "TINFL_DECOMPRESS_MEM_TO_MEM_FAILED";
|
||||
}
|
||||
dst->wi += n;
|
||||
src->ri = src->wi;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* mimic_deflate_decode(wuffs_base__buf1* dst,
|
||||
wuffs_base__buf1* src,
|
||||
uint64_t wlimit,
|
||||
uint64_t rlimit) {
|
||||
return mimic_deflate_zlib_decode(dst, src, wlimit, rlimit, true);
|
||||
}
|
||||
|
||||
const char* mimic_gzip_decode(wuffs_base__buf1* dst,
|
||||
wuffs_base__buf1* src,
|
||||
uint64_t wlimit,
|
||||
uint64_t rlimit) {
|
||||
return "miniz does not implement gzip";
|
||||
}
|
||||
|
||||
const char* mimic_zlib_decode(wuffs_base__buf1* dst,
|
||||
wuffs_base__buf1* src,
|
||||
uint64_t wlimit,
|
||||
uint64_t rlimit) {
|
||||
return mimic_deflate_zlib_decode(dst, src, wlimit, rlimit, false);
|
||||
}
|
||||
|
||||
#else // WUFFS_MIMICLIB_USE_MINIZ_INSTEAD_OF_ZLIB
|
||||
#include "zlib.h"
|
||||
|
||||
uint32_t global_mimiclib_deflate_unused_u32;
|
||||
@@ -175,3 +238,5 @@ const char* mimic_zlib_decode(wuffs_base__buf1* dst,
|
||||
uint64_t rlimit) {
|
||||
return mimic_gzip_zlib_decode(dst, src, wlimit, rlimit, false);
|
||||
}
|
||||
|
||||
#endif // WUFFS_MIMICLIB_USE_MINIZ_INSTEAD_OF_ZLIB
|
||||
@@ -654,7 +654,9 @@ void bench_mimic_gzip_decode_100k() {
|
||||
|
||||
// ---------------- Manifest
|
||||
|
||||
// TODO: move crc32 and gzip tests and benches from std/flate to std/gzip.
|
||||
// TODO: move crc32 and gzip tests and benches from std/deflate to std/gzip.
|
||||
// Note that these crc32 and gzip tests and benches don't work with
|
||||
// WUFFS_MIMICLIB_USE_MINIZ_INSTEAD_OF_ZLIB.
|
||||
|
||||
// The empty comments forces clang-format to place one element per line.
|
||||
proc tests[] = {
|
||||
|
||||
Reference in new issue
Block a user