mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 16:47:28 +01:00
Add zlib (not just raw flate) benchmark.
This commit is contained in:
1 parent
6c8414099a
commit
03572374dd
5 files changed
+142
-12
No files matched your search
+18
-6
@@ -57,15 +57,19 @@ cleanup0:;
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char* mimic_gzip_decode(puffs_base_buf1* dst, puffs_base_buf1* src) {
|
||||
const char* mimic_gzip_zlib_decode(puffs_base_buf1* dst,
|
||||
puffs_base_buf1* src,
|
||||
bool gzip_instead_of_zlib) {
|
||||
const char* ret = NULL;
|
||||
|
||||
z_stream z = {0};
|
||||
const int window_bits = 15;
|
||||
// See inflateInit2 in the zlib manual, or in zlib.h, for details about this
|
||||
// magic gzip_instead_of_zlib constant.
|
||||
const int gzip_instead_of_zlib = 16;
|
||||
int ii2_err = inflateInit2(&z, window_bits | gzip_instead_of_zlib);
|
||||
int window_bits = 15;
|
||||
if (gzip_instead_of_zlib) {
|
||||
// See inflateInit2 in the zlib manual, or in zlib.h, for details about
|
||||
// this magic constant.
|
||||
window_bits |= 16;
|
||||
}
|
||||
int ii2_err = inflateInit2(&z, window_bits);
|
||||
if (ii2_err != Z_OK) {
|
||||
ret = "inflateInit2 failed";
|
||||
goto cleanup0;
|
||||
@@ -107,3 +111,11 @@ cleanup1:;
|
||||
cleanup0:;
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char* mimic_gzip_decode(puffs_base_buf1* dst, puffs_base_buf1* src) {
|
||||
return mimic_gzip_zlib_decode(dst, src, true);
|
||||
}
|
||||
|
||||
const char* mimic_zlib_decode(puffs_base_buf1* dst, puffs_base_buf1* src) {
|
||||
return mimic_gzip_zlib_decode(dst, src, false);
|
||||
}
|
||||
@@ -67,11 +67,26 @@ golden_test flate_romeo_gt = {
|
||||
.src_offset1 = 550, //
|
||||
};
|
||||
|
||||
golden_test gzip_midsummer_gt = {
|
||||
.want_filename = "../../testdata/midsummer.txt", //
|
||||
.src_filename = "../../testdata/midsummer.txt.gz", //
|
||||
};
|
||||
|
||||
golden_test gzip_pi_gt = {
|
||||
.want_filename = "../../testdata/pi.txt", //
|
||||
.src_filename = "../../testdata/pi.txt.gz", //
|
||||
};
|
||||
|
||||
golden_test zlib_midsummer_gt = {
|
||||
.want_filename = "../../testdata/midsummer.txt", //
|
||||
.src_filename = "../../testdata/midsummer.txt.zlib", //
|
||||
};
|
||||
|
||||
golden_test zlib_pi_gt = {
|
||||
.want_filename = "../../testdata/pi.txt", //
|
||||
.src_filename = "../../testdata/pi.txt.zlib", //
|
||||
};
|
||||
|
||||
// ---------------- Flate Tests
|
||||
|
||||
const char* puffs_flate_decode(puffs_base_buf1* dst, puffs_base_buf1* src) {
|
||||
@@ -200,11 +215,26 @@ void test_mimic_flate_decode_romeo() {
|
||||
test_buf1_buf1(mimic_flate_decode, &flate_romeo_gt);
|
||||
}
|
||||
|
||||
void test_mimic_gzip_decode_midsummer() {
|
||||
proc_funcname = __func__;
|
||||
test_buf1_buf1(mimic_gzip_decode, &gzip_midsummer_gt);
|
||||
}
|
||||
|
||||
void test_mimic_gzip_decode_pi() {
|
||||
proc_funcname = __func__;
|
||||
test_buf1_buf1(mimic_gzip_decode, &gzip_pi_gt);
|
||||
}
|
||||
|
||||
void test_mimic_zlib_decode_midsummer() {
|
||||
proc_funcname = __func__;
|
||||
test_buf1_buf1(mimic_zlib_decode, &zlib_midsummer_gt);
|
||||
}
|
||||
|
||||
void test_mimic_zlib_decode_pi() {
|
||||
proc_funcname = __func__;
|
||||
test_buf1_buf1(mimic_zlib_decode, &zlib_pi_gt);
|
||||
}
|
||||
|
||||
#endif // PUFFS_MIMIC
|
||||
|
||||
// ---------------- Flate Benches
|
||||
@@ -243,11 +273,26 @@ void bench_mimic_flate_decode_100k() {
|
||||
bench_buf1_buf1(mimic_flate_decode, &flate_pi_gt, 3000);
|
||||
}
|
||||
|
||||
void bench_mimic_gzip_decode_10k() {
|
||||
proc_funcname = __func__;
|
||||
bench_buf1_buf1(mimic_gzip_decode, &gzip_midsummer_gt, 30000);
|
||||
}
|
||||
|
||||
void bench_mimic_gzip_decode_100k() {
|
||||
proc_funcname = __func__;
|
||||
bench_buf1_buf1(mimic_gzip_decode, &gzip_pi_gt, 3000);
|
||||
}
|
||||
|
||||
void bench_mimic_zlib_decode_10k() {
|
||||
proc_funcname = __func__;
|
||||
bench_buf1_buf1(mimic_zlib_decode, &zlib_midsummer_gt, 30000);
|
||||
}
|
||||
|
||||
void bench_mimic_zlib_decode_100k() {
|
||||
proc_funcname = __func__;
|
||||
bench_buf1_buf1(mimic_zlib_decode, &zlib_pi_gt, 3000);
|
||||
}
|
||||
|
||||
#endif // PUFFS_MIMIC
|
||||
|
||||
// ---------------- Manifest
|
||||
@@ -270,7 +315,10 @@ proc tests[] = {
|
||||
test_mimic_flate_decode_midsummer, //
|
||||
test_mimic_flate_decode_pi, //
|
||||
test_mimic_flate_decode_romeo, //
|
||||
test_mimic_gzip_decode_midsummer, //
|
||||
test_mimic_gzip_decode_pi, //
|
||||
test_mimic_zlib_decode_midsummer, //
|
||||
test_mimic_zlib_decode_pi, //
|
||||
|
||||
#endif // PUFFS_MIMIC
|
||||
|
||||
@@ -292,7 +340,10 @@ proc benches[] = {
|
||||
bench_mimic_flate_decode_1k, //
|
||||
bench_mimic_flate_decode_10k, //
|
||||
bench_mimic_flate_decode_100k, //
|
||||
bench_mimic_gzip_decode_10k, //
|
||||
bench_mimic_gzip_decode_100k, //
|
||||
bench_mimic_zlib_decode_10k, //
|
||||
bench_mimic_zlib_decode_100k, //
|
||||
|
||||
#endif // PUFFS_MIMIC
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Reference in new issue
Block a user