From: Rene Gassmoeller Date: Thu, 8 Aug 2019 16:42:17 +0000 (-0600) Subject: Use default compression for Utilities::pack X-Git-Tag: v9.2.0-rc1~1239^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6871b33d0fcc6f10c399ca2c4aafe3e97dd4f39f;p=dealii.git Use default compression for Utilities::pack --- diff --git a/include/deal.II/base/utilities.h b/include/deal.II/base/utilities.h index 588fabf0e5..12d939994e 100644 --- a/include/deal.II/base/utilities.h +++ b/include/deal.II/base/utilities.h @@ -1215,7 +1215,7 @@ namespace Utilities boost::iostreams::filtering_ostream out; out.push( boost::iostreams::gzip_compressor(boost::iostreams::gzip_params( - boost::iostreams::gzip::best_compression))); + boost::iostreams::gzip::default_compression))); out.push(boost::iostreams::back_inserter(dest_buffer)); boost::archive::binary_oarchive archive(out); diff --git a/tests/base/utilities_pack_unpack_07.cc b/tests/base/utilities_pack_unpack_07.cc new file mode 100644 index 0000000000..7d2acedc78 --- /dev/null +++ b/tests/base/utilities_pack_unpack_07.cc @@ -0,0 +1,110 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// tests the influence of different compression options for +// Utilities::pack/unpack +// (based upon "utilities_pack_unpack_06") + + +#include +#include +#include + +#include + +#include "../tests.h" + +using namespace dealii; + + +template +void +check(const double (&array)[N]) +{ + // ----- PACK ----- + std::vector array_compressed, array_uncompressed; + + TimerOutput computing_timer(std::cout, + TimerOutput::never, + TimerOutput::wall_times); + +#ifdef DEAL_II_WITH_ZLIB + // default option should work for compression + { + TimerOutput::Scope timer_section(computing_timer, "Pack compressed"); + Utilities::pack(array, array_compressed, true); + } +#endif + + { + TimerOutput::Scope timer_section(computing_timer, "Pack uncompressed"); + Utilities::pack(array, array_uncompressed, false); + } + + // computing_timer.print_summary(); + + // check if compression has been invoked by comparing sizes + deallog << "unpacked array: " << sizeof(array) << std::endl; + + deallog << "packed array without compression: " << array_uncompressed.size() + << std::endl; + +#ifdef DEAL_II_WITH_ZLIB + deallog << "packed array with compression: " << array_compressed.size() + << std::endl; +#endif +} + + +void +test() +{ + // pick large data types and arrays that could be compressed, + // and check for both compression options + const unsigned int N = 10000; + double x2[N]; + + std::default_random_engine generator(0); + std::uniform_real_distribution distribution(0.0, 1.0); + + // Test easily compressible data. + // Default compression is much faster than best compression. + for (unsigned int i = 0; i < N; ++i) + { + x2[i] = i; + } + + check(x2); + + // Test random data, which is nearly incompressible. + // Default compression is equally fast as best compression. + for (unsigned int i = 0; i < N; ++i) + { + x2[i] = distribution(generator); + } + + check(x2); + + deallog << "OK!" << std::endl; +} + +int +main() +{ + initlog(); + + test(); +} diff --git a/tests/base/utilities_pack_unpack_07.with_zlib=off.output b/tests/base/utilities_pack_unpack_07.with_zlib=off.output new file mode 100644 index 0000000000..6ca43eec47 --- /dev/null +++ b/tests/base/utilities_pack_unpack_07.with_zlib=off.output @@ -0,0 +1,6 @@ + +DEAL::unpacked array: 80000 +DEAL::packed array without compression: 80048 +DEAL::unpacked array: 80000 +DEAL::packed array without compression: 80048 +DEAL::OK! diff --git a/tests/base/utilities_pack_unpack_07.with_zlib=on.debug.output b/tests/base/utilities_pack_unpack_07.with_zlib=on.debug.output new file mode 100644 index 0000000000..6c68b4bad0 --- /dev/null +++ b/tests/base/utilities_pack_unpack_07.with_zlib=on.debug.output @@ -0,0 +1,8 @@ + +DEAL::unpacked array: 80000 +DEAL::packed array without compression: 80048 +DEAL::packed array with compression: 14697 +DEAL::unpacked array: 80000 +DEAL::packed array without compression: 80048 +DEAL::packed array with compression: 75558 +DEAL::OK! diff --git a/tests/base/utilities_pack_unpack_07.with_zlib=on.release.output b/tests/base/utilities_pack_unpack_07.with_zlib=on.release.output new file mode 100644 index 0000000000..5a74ae434e --- /dev/null +++ b/tests/base/utilities_pack_unpack_07.with_zlib=on.release.output @@ -0,0 +1,8 @@ + +DEAL::unpacked array: 80000 +DEAL::packed array without compression: 80048 +DEAL::packed array with compression: 14697 +DEAL::unpacked array: 80000 +DEAL::packed array without compression: 80048 +DEAL::packed array with compression: 75550 +DEAL::OK!