]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use default compression for Utilities::pack 8513/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 8 Aug 2019 16:42:17 +0000 (10:42 -0600)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Tue, 13 Aug 2019 20:03:36 +0000 (13:03 -0700)
include/deal.II/base/utilities.h
tests/base/utilities_pack_unpack_07.cc [new file with mode: 0644]
tests/base/utilities_pack_unpack_07.with_zlib=off.output [new file with mode: 0644]
tests/base/utilities_pack_unpack_07.with_zlib=on.debug.output [new file with mode: 0644]
tests/base/utilities_pack_unpack_07.with_zlib=on.release.output [new file with mode: 0644]

index 588fabf0e561ad126eb51773bfc4e5c62e54a2a3..12d939994e3bfb40c9e488089302c711ed8ac694 100644 (file)
@@ -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 (file)
index 0000000..7d2aced
--- /dev/null
@@ -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 <deal.II/base/point.h>
+#include <deal.II/base/timer.h>
+#include <deal.II/base/utilities.h>
+
+#include <random>
+
+#include "../tests.h"
+
+using namespace dealii;
+
+
+template <int N>
+void
+check(const double (&array)[N])
+{
+  // ----- PACK -----
+  std::vector<char> 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<double> 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 (file)
index 0000000..6ca43ee
--- /dev/null
@@ -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 (file)
index 0000000..6c68b4b
--- /dev/null
@@ -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 (file)
index 0000000..5a74ae4
--- /dev/null
@@ -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!

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.