]>
cygwin.com Git - cygwin-apps/setup.git/blob - rsync/stats.c
1 /*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
5 * Copyright (C) 2000, 2001 by Martin Pool <mbp@samba.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #ifdef HAVE_SYS_FILE_H
40 * TODO: Other things to show in statistics:
42 * Number of input and output bytes.
44 * Number of times we blocked waiting for input or output.
50 rs_log_stats(rs_stats_t
const *stats
)
54 rs_format_stats(stats
, buf
, sizeof buf
- 1);
55 rs_log(RS_LOG_INFO
|RS_LOG_NONAME
, "%s", buf
);
62 * \brief Return a human-readable representation of statistics.
64 * The string is truncated if it does not fit. 100 characters should
65 * be sufficient space.
67 * \param stats Statistics from an encoding or decoding operation.
69 * \param buf Buffer to receive result.
70 * \param size Size of buffer.
74 rs_format_stats(rs_stats_t
const * stats
,
75 char *buf
, size_t size
)
77 char const *op
= stats
->op
;
83 len
= snprintf(buf
, size
, "%s statistics: ", op
);
85 if (stats
->lit_cmds
) {
86 len
+= snprintf(buf
+len
, size
-len
,
87 "literal[%d cmds, %.0f bytes, %.0f cmdbytes] ",
89 (double) stats
->lit_bytes
,
90 (double) stats
->lit_cmdbytes
);
93 if (stats
->sig_cmds
) {
94 len
+= snprintf(buf
+len
, size
-len
,
95 "in-place-signature[%.0f cmds, %.0f bytes] ",
96 (double) stats
->sig_cmds
,
97 (double) stats
->sig_bytes
);
100 if (stats
->copy_cmds
|| stats
->false_matches
) {
101 len
+= snprintf(buf
+len
, size
-len
,
102 "copy[%.0f cmds, %.0f bytes, %.0f false, %.0f cmdbytes]",
103 (double) stats
->copy_cmds
,
104 (double) stats
->copy_bytes
,
105 (double) stats
->false_matches
,
106 (double) stats
->copy_cmdbytes
);
110 if (stats
->sig_blocks
) {
111 len
+= snprintf(buf
+len
, size
-len
,
112 "signature[%.0f blocks, %.0f bytes per block]",
113 (double) stats
->sig_blocks
,
114 (double) stats
->block_len
);
This page took 0.041881 seconds and 5 git commands to generate.