Home | History | Annotate | Download | only in src
      1 /* stats1b.h -- statistics for the the LZO library
      2 
      3    This file is part of the LZO real-time data compression library.
      4 
      5    Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
      6    All Rights Reserved.
      7 
      8    The LZO library is free software; you can redistribute it and/or
      9    modify it under the terms of the GNU General Public License as
     10    published by the Free Software Foundation; either version 2 of
     11    the License, or (at your option) any later version.
     12 
     13    The LZO library is distributed in the hope that it will be useful,
     14    but WITHOUT ANY WARRANTY; without even the implied warranty of
     15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16    GNU General Public License for more details.
     17 
     18    You should have received a copy of the GNU General Public License
     19    along with the LZO library; see the file COPYING.
     20    If not, write to the Free Software Foundation, Inc.,
     21    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
     22 
     23    Markus F.X.J. Oberhumer
     24    <markus (at) oberhumer.com>
     25    http://www.oberhumer.com/opensource/lzo/
     26  */
     27 
     28 
     29 /* WARNING: this file should *not* be used by applications. It is
     30    part of the implementation of the library and is subject
     31    to change.
     32  */
     33 
     34 
     35 #ifndef __LZO_STATS1B_H
     36 #define __LZO_STATS1B_H 1
     37 
     38 #ifdef __cplusplus
     39 extern "C" {
     40 #endif
     41 
     42 
     43 /***********************************************************************
     44 // Collect statistical information when compressing.
     45 // Useful for finetuning the compression algorithm.
     46 // Examine the symbol 'lzo1b_stats' with a debugger.
     47 ************************************************************************/
     48 
     49 #if (LZO_COLLECT_STATS)
     50 #  define LZO_STATS(expr)   expr
     51 #else
     52 #  define LZO_STATS(expr)   ((void) 0)
     53 #endif
     54 
     55 
     56 #if (LZO_COLLECT_STATS)
     57 
     58 typedef struct
     59 {
     60 /* algorithm configuration */
     61     unsigned r_bits;
     62     unsigned m3o_bits;
     63     unsigned dd_bits;
     64     unsigned clevel;
     65 
     66 /* internal configuration */
     67     unsigned d_bits;
     68     long min_lookahead;
     69     long max_lookbehind;
     70     const char *compress_id;
     71 
     72 /* counts */
     73     long lit_runs;
     74     long r0short_runs;
     75     long r0fast_runs;
     76     long r0long_runs;
     77     long m1_matches;
     78     long m2_matches;
     79     long m3_matches;
     80     long m4_matches;
     81     long r1_matches;
     82 
     83 /* */
     84     long lit_run[R0MIN];
     85     long m2_match[M2_MAX_LEN + 1];
     86     long m3_match[M3_MAX_LEN + 1];
     87 #if (M3O_BITS < 8)
     88     long lit_runs_after_m3_match;
     89     long lit_run_after_m3_match[LZO_SIZE(8-M3O_BITS)];
     90 #endif
     91 
     92 /* */
     93     long matches;
     94     long match_bytes;
     95     long literals;
     96     long literal_overhead;
     97     long literal_bytes;
     98     double literal_overhead_percent;
     99 
    100 /* */
    101     long unused_dict_entries;
    102     double unused_dict_entries_percent;
    103 
    104 /* */
    105     long in_len;
    106     long out_len;
    107 }
    108 lzo1b_stats_t;
    109 
    110 
    111 void _lzo1b_stats_init(lzo1b_stats_t *lzo_stats);
    112 void _lzo1b_stats_calc(lzo1b_stats_t *lzo_stats);
    113 
    114 extern lzo1b_stats_t * const lzo1b_stats;
    115 
    116 #define lzo_stats_t     lzo1b_stats_t
    117 #define lzo_stats       lzo1b_stats
    118 
    119 #endif
    120 
    121 
    122 #ifdef __cplusplus
    123 } /* extern "C" */
    124 #endif
    125 
    126 #endif /* already included */
    127 
    128 /*
    129 vi:ts=4:et
    130 */
    131