Add a throughput_counter concept.

Example benchstat summary of "puffs bench -mimic" output below, with
some blank lines added for clarity.

For example, gzip and zlib both add a checksum (crc32 and adler32
respectively) to raw flate. The headline mimic_{gzip,zlib}_decode_100k
numbers are 386µs and 347µs per op. Subtracting 73.2µs and 34.3µs for
the checksum times from the headline times give the same number: 313µs.

This 313µs differs from 358µs for raw flate (mimic_flate_decode_100k)
because zlib takes two different code paths for wrapped vs raw flate. In
the zlib source code, this is inflate.c vs infback.c respectively.

----
name                             time/op

mimic_adler32_10k/clang            3.74µs ± 1%
mimic_adler32_100k/clang           34.3µs ± 1%
mimic_crc32_10k/clang              8.10µs ± 1%
mimic_crc32_100k/clang             73.2µs ± 0%

mimic_flate_decode_1k/clang        4.31µs ± 1%
mimic_flate_decode_10k/clang       42.1µs ± 1%
mimic_flate_decode_100k/clang       358µs ± 1%
mimic_gzip_decode_10k/clang        49.8µs ± 1%
mimic_gzip_decode_100k/clang        386µs ± 0%
mimic_zlib_decode_10k/clang        45.3µs ± 0%
mimic_zlib_decode_100k/clang        347µs ± 1%

mimic_adler32_10k/gcc              3.72µs ± 1%
mimic_adler32_100k/gcc             34.3µs ± 2%
mimic_crc32_10k/gcc                8.06µs ± 0%
mimic_crc32_100k/gcc               73.1µs ± 0%

mimic_flate_decode_1k/gcc          4.26µs ± 0%
mimic_flate_decode_10k/gcc         42.0µs ± 0%
mimic_flate_decode_100k/gcc         356µs ± 0%
mimic_gzip_decode_10k/gcc          50.4µs ± 4%
mimic_gzip_decode_100k/gcc          390µs ± 2%
mimic_zlib_decode_10k/gcc          45.6µs ± 1%
mimic_zlib_decode_100k/gcc          348µs ± 1%

puffs_gif_lzw_decode_20k/clang      151µs ± 0%
puffs_gif_lzw_decode_100k/clang     566µs ± 0%
puffs_gif_decode_1k/clang          2.74µs ± 1%
puffs_gif_decode_10k/clang         73.8µs ± 0%
puffs_gif_decode_100k/clang        1.13ms ± 0%
puffs_gif_decode_1000k/clang       7.99ms ± 0%

mimic_gif_decode_1k/clang          6.44µs ± 0%
mimic_gif_decode_10k/clang          107µs ± 0%
mimic_gif_decode_100k/clang        1.38ms ± 0%
mimic_gif_decode_1000k/clang       9.79ms ± 0%

puffs_gif_lzw_decode_20k/gcc        127µs ± 0%
puffs_gif_lzw_decode_100k/gcc       501µs ± 0%
puffs_gif_decode_1k/gcc            2.45µs ± 1%
puffs_gif_decode_10k/gcc           65.1µs ± 0%
puffs_gif_decode_100k/gcc          1.01ms ± 0%
puffs_gif_decode_1000k/gcc         7.16ms ± 1%

mimic_gif_decode_1k/gcc            6.66µs ± 2%
mimic_gif_decode_10k/gcc            108µs ± 1%
mimic_gif_decode_100k/gcc          1.39ms ± 0%
mimic_gif_decode_1000k/gcc         9.93ms ± 1%

name                             speed

mimic_adler32_10k/clang          2.96GB/s ± 1%
mimic_adler32_100k/clang         2.91GB/s ± 1%
mimic_crc32_10k/clang            1.37GB/s ± 1%
mimic_crc32_100k/clang           1.37GB/s ± 0%

mimic_flate_decode_1k/clang       219MB/s ± 1%
mimic_flate_decode_10k/clang      263MB/s ± 1%
mimic_flate_decode_100k/clang     280MB/s ± 1%
mimic_gzip_decode_10k/clang       222MB/s ± 1%
mimic_gzip_decode_100k/clang      259MB/s ± 0%
mimic_zlib_decode_10k/clang       244MB/s ± 0%
mimic_zlib_decode_100k/clang      288MB/s ± 1%

mimic_adler32_10k/gcc            2.97GB/s ± 1%
mimic_adler32_100k/gcc           2.92GB/s ± 2%
mimic_crc32_10k/gcc              1.37GB/s ± 0%
mimic_crc32_100k/gcc             1.37GB/s ± 0%

mimic_flate_decode_1k/gcc         221MB/s ± 0%
mimic_flate_decode_10k/gcc        264MB/s ± 0%
mimic_flate_decode_100k/gcc       281MB/s ± 0%
mimic_gzip_decode_10k/gcc         219MB/s ± 4%
mimic_gzip_decode_100k/gcc        256MB/s ± 2%
mimic_zlib_decode_10k/gcc         243MB/s ± 1%
mimic_zlib_decode_100k/gcc        287MB/s ± 1%

puffs_gif_lzw_decode_20k/clang    128MB/s ± 0%
puffs_gif_lzw_decode_100k/clang   177MB/s ± 0%
puffs_gif_decode_1k/clang         373MB/s ± 1%
puffs_gif_decode_10k/clang        137MB/s ± 0%
puffs_gif_decode_100k/clang       122MB/s ± 0%
puffs_gif_decode_1000k/clang      125MB/s ± 0%

mimic_gif_decode_1k/clang         159MB/s ± 0%
mimic_gif_decode_10k/clang       94.2MB/s ± 0%
mimic_gif_decode_100k/clang       100MB/s ± 0%
mimic_gif_decode_1000k/clang      102MB/s ± 0%

puffs_gif_lzw_decode_20k/gcc      151MB/s ± 0%
puffs_gif_lzw_decode_100k/gcc     200MB/s ± 0%
puffs_gif_decode_1k/gcc           418MB/s ± 1%
puffs_gif_decode_10k/gcc          155MB/s ± 0%
puffs_gif_decode_100k/gcc         137MB/s ± 0%
puffs_gif_decode_1000k/gcc        140MB/s ± 1%

mimic_gif_decode_1k/gcc           154MB/s ± 2%
mimic_gif_decode_10k/gcc         93.0MB/s ± 1%
mimic_gif_decode_100k/gcc        98.9MB/s ± 0%
mimic_gif_decode_1000k/gcc        101MB/s ± 1%
----
This commit is contained in:
Nigel Tao committed 2017-07-14 13:09:45 +10:00
1 parent 8be6dc3394
commit 85610b5df2
2 files changed
+38 -17

No files matched your search

+14 -14
View File
@@ -249,17 +249,17 @@ void test_mimic_zlib_decode_pi() {
void bench_puffs_flate_decode_1k() {
proc_funcname = __func__;
bench_buf1_buf1(puffs_flate_decode, &flate_romeo_gt, 200000);
bench_buf1_buf1(puffs_flate_decode, tc_dst, &flate_romeo_gt, 200000);
}
void bench_puffs_flate_decode_10k() {
proc_funcname = __func__;
bench_buf1_buf1(puffs_flate_decode, &flate_midsummer_gt, 30000);
bench_buf1_buf1(puffs_flate_decode, tc_dst, &flate_midsummer_gt, 30000);
}
void bench_puffs_flate_decode_100k() {
proc_funcname = __func__;
bench_buf1_buf1(puffs_flate_decode, &flate_pi_gt, 3000);
bench_buf1_buf1(puffs_flate_decode, tc_dst, &flate_pi_gt, 3000);
}
// ---------------- Mimic Benches
@@ -268,57 +268,57 @@ void bench_puffs_flate_decode_100k() {
void bench_mimic_adler32_10k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_adler32, &checksum_midsummer_gt, 30000);
bench_buf1_buf1(mimic_adler32, tc_src, &checksum_midsummer_gt, 30000);
}
void bench_mimic_adler32_100k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_adler32, &checksum_pi_gt, 3000);
bench_buf1_buf1(mimic_adler32, tc_src, &checksum_pi_gt, 3000);
}
void bench_mimic_crc32_10k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_crc32, &checksum_midsummer_gt, 30000);
bench_buf1_buf1(mimic_crc32, tc_src, &checksum_midsummer_gt, 30000);
}
void bench_mimic_crc32_100k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_crc32, &checksum_pi_gt, 3000);
bench_buf1_buf1(mimic_crc32, tc_src, &checksum_pi_gt, 3000);
}
void bench_mimic_flate_decode_1k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_flate_decode, &flate_romeo_gt, 200000);
bench_buf1_buf1(mimic_flate_decode, tc_dst, &flate_romeo_gt, 200000);
}
void bench_mimic_flate_decode_10k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_flate_decode, &flate_midsummer_gt, 30000);
bench_buf1_buf1(mimic_flate_decode, tc_dst, &flate_midsummer_gt, 30000);
}
void bench_mimic_flate_decode_100k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_flate_decode, &flate_pi_gt, 3000);
bench_buf1_buf1(mimic_flate_decode, tc_dst, &flate_pi_gt, 3000);
}
void bench_mimic_gzip_decode_10k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_gzip_decode, &gzip_midsummer_gt, 30000);
bench_buf1_buf1(mimic_gzip_decode, tc_dst, &gzip_midsummer_gt, 30000);
}
void bench_mimic_gzip_decode_100k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_gzip_decode, &gzip_pi_gt, 3000);
bench_buf1_buf1(mimic_gzip_decode, tc_dst, &gzip_pi_gt, 3000);
}
void bench_mimic_zlib_decode_10k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_zlib_decode, &zlib_midsummer_gt, 30000);
bench_buf1_buf1(mimic_zlib_decode, tc_dst, &zlib_midsummer_gt, 30000);
}
void bench_mimic_zlib_decode_100k() {
proc_funcname = __func__;
bench_buf1_buf1(mimic_zlib_decode, &zlib_pi_gt, 3000);
bench_buf1_buf1(mimic_zlib_decode, tc_dst, &zlib_pi_gt, 3000);
}
#endif // PUFFS_MIMIC
+24 -3
View File
@@ -268,8 +268,19 @@ bool buf1s_equal(const char* prefix,
return false;
}
// throughput_counter is whether to count dst or src bytes, or neither, when
// calculating a benchmark's MB/s throughput number.
//
// Decoders typically use tc_dst. Encoders and hashes typically use tc_src.
typedef enum {
tc_neither = 0,
tc_dst = 1,
tc_src = 2,
} throughput_counter;
void proc_buf1_buf1(const char* (*codec_func)(puffs_base_buf1*,
puffs_base_buf1*),
throughput_counter tc,
golden_test* gt,
uint64_t reps,
bool bench) {
@@ -317,7 +328,16 @@ void proc_buf1_buf1(const char* (*codec_func)(puffs_base_buf1*,
FAIL("%s", s);
return;
}
n_bytes += got.wi;
switch (tc) {
case tc_neither:
break;
case tc_dst:
n_bytes += got.wi;
break;
case tc_src:
n_bytes += src.ri - gt->src_offset0;
break;
}
}
if (bench) {
bench_finish(reps, n_bytes);
@@ -336,15 +356,16 @@ void proc_buf1_buf1(const char* (*codec_func)(puffs_base_buf1*,
void bench_buf1_buf1(const char* (*codec_func)(puffs_base_buf1*,
puffs_base_buf1*),
throughput_counter tc,
golden_test* gt,
uint64_t reps) {
proc_buf1_buf1(codec_func, gt, reps, true);
proc_buf1_buf1(codec_func, tc, gt, reps, true);
}
void test_buf1_buf1(const char* (*codec_func)(puffs_base_buf1*,
puffs_base_buf1*),
golden_test* gt) {
proc_buf1_buf1(codec_func, gt, 1, false);
proc_buf1_buf1(codec_func, 0, gt, 1, false);
}
#endif // PUFFS_BASE_HEADER_H