1 /* 2 Copyright 2012-2018 Jyri J. Virkki <jyri@virkki.com> 3 4 This file is part of dupd. 5 6 dupd is free software: you can redistribute it and/or modify it 7 under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 dupd is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with dupd. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef _DUPD_STATS_H 21 #define _DUPD_STATS_H 22 23 #include <inttypes.h> 24 #include <stdint.h> 25 26 #define ROUNDS 2 27 #define ROUND1 0 28 #define ROUND2 1 29 #define MAX_HASHER_THREADS 2 30 31 extern pthread_mutex_t stats_lock; 32 33 extern int stats_sets_processed[ROUNDS]; 34 extern int stats_sets_dup_done[ROUNDS]; 35 extern int stats_sets_dup_not[ROUNDS]; 36 extern int stats_sets_full_read[ROUNDS]; 37 extern int stats_sets_part_read[ROUNDS]; 38 extern int stats_duplicate_groups; 39 extern int stats_reader_loops[ROUNDS]; 40 extern int stats_hasher_loops[ROUNDS][MAX_HASHER_THREADS]; 41 extern int stats_hasher_queue_len[MAX_HASHER_THREADS]; 42 43 extern long stats_process_start; 44 extern long stats_process_duration; 45 46 extern uint64_t stats_total_bytes; 47 extern uint64_t stats_total_bytes_read; 48 extern uint64_t stats_total_bytes_hashed; 49 extern uint64_t stats_comparison_bytes_read; 50 extern uint32_t stats_max_pathlist; 51 extern uint64_t stats_max_pathlist_size; 52 extern uint32_t stats_path_list_entries; 53 extern int stats_most_dups; 54 extern int stats_all_blocks_count; 55 extern int stats_duplicate_files; 56 extern int stats_full_hash_first; 57 extern int stats_full_hash_second; 58 extern int stats_mid_blocks_count; 59 extern int stats_one_block_hash_first; 60 61 extern int stats_partial_hash_second; 62 extern int stats_set_dups_done_full_round; 63 extern int stats_set_dup_done_round_one; 64 extern int stats_set_dup_done_round_two; 65 extern int stats_set_full_round; 66 extern int stats_set_no_dups_full_round; 67 extern int stats_set_no_dups_round_one; 68 extern int stats_set_no_dups_round_two; 69 extern int stats_set_round_one; 70 extern int stats_set_round_two; 71 extern int stats_single_block_count; 72 73 extern int stats_size_list_done; 74 extern int stats_three_file_compare; 75 extern int stats_two_file_compare; 76 extern int stats_uniques_saved; 77 extern long stats_size_list_avg; 78 //extern uint32_t stats_files_count; 79 extern int stats_files_ignored; 80 extern int stats_files_error; 81 extern uint64_t stats_avg_file_size; 82 extern long stats_time_scan; 83 extern long stats_time_process; 84 extern long stats_time_total; 85 extern long stats_main_start; 86 extern int path_buffer_realloc; 87 extern int stats_hashlist_path_realloc; 88 extern int stats_hash_list_len_inc; 89 extern int scan_list_usage_max; 90 extern int scan_list_resizes; 91 extern uint64_t stats_read_buffers_allocated; 92 extern int stats_flusher_active; 93 extern uint32_t stats_fiemap_total_blocks; 94 extern uint32_t stats_fiemap_zero_blocks; 95 96 extern uint32_t count_sets_first_read; 97 extern uint32_t count_files_completed; 98 extern uint32_t stats_sets_first_read_completed; 99 100 101 102 103 104 // Keep 105 extern uint32_t s_stats_size_list_count; 106 107 extern uint32_t s_total_files_seen; 108 extern uint32_t s_files_skip_error; 109 extern uint32_t s_files_skip_notfile; 110 extern uint32_t s_files_skip_badsep; 111 extern uint32_t s_files_cant_read; 112 extern uint32_t s_files_hl_skip; 113 extern uint32_t s_files_too_small; 114 extern uint32_t s_files_processed; 115 extern uint32_t s_files_in_sizetree; 116 extern uint32_t s_files_dropped; 117 extern uint32_t s_files_completed_dups; 118 extern uint32_t s_files_completed_unique; 119 120 extern int current_open_files; 121 122 123 /** *************************************************************************** 124 * Print some stats to stdout depending on verbosity. 125 * 126 * Parameters: none 127 * 128 * Return: none 129 * 130 */ 131 void report_stats(); 132 133 134 /** *************************************************************************** 135 * Save stats to a disk file. 136 * 137 */ 138 void save_stats(); 139 140 141 /** *************************************************************************** 142 * Increment counter of read buffers allocated. 143 * 144 */ 145 void inc_stats_read_buffers_allocated(int bytes); 146 147 148 /** *************************************************************************** 149 * Decrement counter of read buffers allocated. 150 * 151 */ 152 void dec_stats_read_buffers_allocated(int bytes); 153 154 155 /** *************************************************************************** 156 * Increase counter of unique files by one. 157 * 158 */ 159 void increase_unique_counter(); 160 161 162 /** *************************************************************************** 163 * Increase counter of duplicate files by n. 164 * 165 */ 166 void increase_dup_counter(int n); 167 168 169 /** *************************************************************************** 170 * Increase counter of sets which have had initial block read. 171 * 172 */ 173 void increase_sets_first_read(); 174 175 176 /** *************************************************************************** 177 * Increase counters of sets completed by the initial block read. 178 * 179 */ 180 void increase_sets_first_read_completed(); 181 182 183 /** *************************************************************************** 184 * Update counter of open files. 185 * 186 */ 187 void update_open_files(int n); 188 189 190 #endif 191