xref: /titanic_51/usr/src/cmd/sort/common/statistics.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2000-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include "statistics.h"
30 
31 static sort_statistics_t *run_stats;
32 
33 void
34 stats_init(sort_statistics_t *s)
35 {
36 	run_stats = s;
37 	memset(s, 0, sizeof (sort_statistics_t));
38 }
39 
40 void
41 stats_display()
42 {
43 	(void) fprintf(stderr,
44 	    "Lines fetched:      %20llu\n"
45 	    "Lines shelved:      %20llu\n"
46 	    "Lines put:          %20llu\n"
47 	    "Lines put uniquely: %20llu\n"
48 	    "Lines not unique:   %20llu\n"
49 	    "Input files:        %20u\n"
50 	    "Merge files:        %20u\n"
51 	    "Subfiles:           %20llu\n"
52 	    "TQS calls:          %20llu\n"
53 	    "Swaps:              %20llu\n"
54 	    "Available memory:   %20llu\n"
55 	    "Insert filled input:%20llu\n"
56 	    "Insert filled up:   %20llu\n"
57 	    "Insert filled down: %20llu\n"
58 	    "TQS calls:          %20llu\n"
59 	    "Convert reallocs:   %20llu\n"
60 	    "Line conversions:   %20llu\n",
61 	    run_stats->st_fetched_lines,
62 	    run_stats->st_shelved_lines,
63 	    run_stats->st_put_lines,
64 	    run_stats->st_put_unique_lines,
65 	    run_stats->st_not_unique_lines,
66 	    run_stats->st_input_files,
67 	    run_stats->st_merge_files,
68 	    run_stats->st_subfiles,
69 	    run_stats->st_tqs_calls,
70 	    run_stats->st_swaps,
71 	    run_stats->st_avail_mem,
72 	    run_stats->st_insert_full_input,
73 	    run_stats->st_insert_full_up,
74 	    run_stats->st_insert_full_down,
75 	    run_stats->st_tqs_calls,
76 	    run_stats->st_convert_reallocs,
77 	    run_stats->st_line_conversions);
78 }
79 
80 void
81 stats_incr_subfiles()
82 {
83 	run_stats->st_subfiles++;
84 }
85 
86 void
87 stats_incr_fetches()
88 {
89 	run_stats->st_fetched_lines++;
90 }
91 
92 void
93 stats_incr_shelves()
94 {
95 	run_stats->st_shelved_lines++;
96 }
97 
98 void
99 stats_incr_puts()
100 {
101 	run_stats->st_put_lines++;
102 }
103 
104 void
105 stats_incr_swaps()
106 {
107 	run_stats->st_swaps++;
108 }
109 
110 void
111 stats_set_input_files(uint_t n)
112 {
113 	run_stats->st_input_files = n;
114 }
115 
116 void
117 stats_incr_input_files()
118 {
119 	run_stats->st_input_files++;
120 }
121 
122 void
123 stats_set_merge_files(uint_t n)
124 {
125 	run_stats->st_merge_files = n;
126 }
127 
128 void
129 stats_incr_merge_files()
130 {
131 	run_stats->st_merge_files++;
132 }
133 
134 void
135 stats_set_available_memory(uint64_t a)
136 {
137 	run_stats->st_avail_mem = a;
138 }
139 
140 void
141 stats_incr_insert_filled_input()
142 {
143 	run_stats->st_insert_full_input++;
144 }
145 
146 void
147 stats_incr_insert_filled_upward()
148 {
149 	run_stats->st_insert_full_up++;
150 }
151 
152 void
153 stats_incr_insert_filled_downward()
154 {
155 	run_stats->st_insert_full_down++;
156 }
157 
158 void
159 stats_incr_tqs_calls()
160 {
161 	run_stats->st_tqs_calls++;
162 }
163 
164 void
165 stats_incr_put_unique()
166 {
167 	run_stats->st_put_unique_lines++;
168 }
169 
170 void
171 stats_incr_not_unique()
172 {
173 	run_stats->st_not_unique_lines++;
174 }
175 
176 void
177 stats_incr_convert_reallocs()
178 {
179 	run_stats->st_convert_reallocs++;
180 }
181 
182 void
183 stats_incr_line_conversions()
184 {
185 	run_stats->st_line_conversions++;
186 }
187