From: Lasse Collin Date: Fri, 25 Apr 2008 10:41:29 +0000 (+0300) Subject: Added memusage.c to debug directory. X-Git-Tag: upstream/5.1.3~753 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3ba30243c75c13d094de1793f9c58acdbacc692;p=platform%2Fupstream%2Fxz.git Added memusage.c to debug directory. --- diff --git a/debug/Makefile.am b/debug/Makefile.am index b935300..71ca7e4 100644 --- a/debug/Makefile.am +++ b/debug/Makefile.am @@ -15,7 +15,8 @@ noinst_PROGRAMS = \ repeat \ sync_flush \ - full_flush + full_flush \ + memusage AM_CPPFLAGS = \ -I@top_srcdir@/src/common \ diff --git a/debug/memusage.c b/debug/memusage.c new file mode 100644 index 0000000..0716f5a --- /dev/null +++ b/debug/memusage.c @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////// +// +/// \file memusage.c +/// \brief Calculates memory usage using lzma_memory_usage() +/// +// Copyright (C) 2008 Lasse Collin +// +// This library is free software; you can 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +/////////////////////////////////////////////////////////////////////////////// + +#include "sysdefs.h" +#include + +int +main(void) +{ + + lzma_options_lzma lzma = { + .dictionary_size = (1 << 27) + (1 << 26), + .literal_context_bits = 3, + .literal_pos_bits = 0, + .pos_bits = 2, + .preset_dictionary = NULL, + .preset_dictionary_size = 0, + .mode = LZMA_MODE_BEST, + .fast_bytes = 48, + .match_finder = LZMA_MF_BT4, + .match_finder_cycles = 0, + }; + +/* + lzma_options_filter filters[] = { + { LZMA_FILTER_LZMA, + (lzma_options_lzma *)&lzma_preset_lzma[6 - 1] }, + { UINT64_MAX, NULL } + }; +*/ + lzma_options_filter filters[] = { + { LZMA_FILTER_LZMA, &lzma }, + { UINT64_MAX, NULL } + }; + + printf("%u MiB\n", lzma_memory_usage(filters, true)); + + return 0; +}