diff options
author | Sage Weil <sage@redhat.com> | 2016-05-19 13:55:03 +0200 |
---|---|---|
committer | Sage Weil <sage@redhat.com> | 2016-06-01 17:38:51 +0200 |
commit | 07d1e43abf65e0a9f061371d2c9a476052ca8e3c (patch) | |
tree | 98e8ad1f8f45719d1d7a4ad41ff3b7004606d960 /src/test | |
parent | unittest_bluestore_types: run csum tests on all algorithms (diff) | |
download | ceph-07d1e43abf65e0a9f061371d2c9a476052ca8e3c.tar.xz ceph-07d1e43abf65e0a9f061371d2c9a476052ca8e3c.zip |
unittest_bluestore_types: benchmark different csum methods
crc32c wins on my laptop.
Signed-off-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/objectstore/test_bluestore_types.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/objectstore/test_bluestore_types.cc b/src/test/objectstore/test_bluestore_types.cc index 156d5eca6aa..422cf9c6131 100644 --- a/src/test/objectstore/test_bluestore_types.cc +++ b/src/test/objectstore/test_bluestore_types.cc @@ -5,6 +5,7 @@ #include "os/bluestore/bluestore_types.h" #include "gtest/gtest.h" #include "include/stringify.h" +#include "common/ceph_time.h" #include <sstream> @@ -238,6 +239,32 @@ TEST(bluestore_blob_t, calc_csum) } } +TEST(bluestore_blob_t, csum_bench) +{ + bufferlist bl; + bufferptr bp(10485760); + for (char *a = bp.c_str(); a < bp.c_str() + bp.length(); ++a) + *a = (unsigned long)a & 0xff; + bl.append(bp); + int count = 256; + for (unsigned csum_type = 1; + csum_type < bluestore_blob_t::CSUM_MAX; + ++csum_type) { + bluestore_blob_t b; + b.init_csum(csum_type, 12, bl.length()); + ceph::mono_clock::time_point start = ceph::mono_clock::now(); + for (int i = 0; i<count; ++i) { + b.calc_csum(0, bl); + } + ceph::mono_clock::time_point end = ceph::mono_clock::now(); + auto dur = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start); + double mbsec = (double)count * (double)bl.length() / 1000000.0 / (double)dur.count() * 1000000000.0; + cout << "csum_type " << bluestore_blob_t::get_csum_type_string(csum_type) + << ", " << dur << " seconds, " + << mbsec << " MB/sec" << std::endl; + } +} + TEST(bluestore_onode_t, find_lextent) { bluestore_onode_t on; |