diff options
Diffstat (limited to 'src/lib/libssl/src/crypto/lhash/lh_stats.c')
-rw-r--r-- | src/lib/libssl/src/crypto/lhash/lh_stats.c | 263 |
1 files changed, 136 insertions, 127 deletions
diff --git a/src/lib/libssl/src/crypto/lhash/lh_stats.c b/src/lib/libssl/src/crypto/lhash/lh_stats.c index 815615e338..34c7d77cb1 100644 --- a/src/lib/libssl/src/crypto/lhash/lh_stats.c +++ b/src/lib/libssl/src/crypto/lhash/lh_stats.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -70,179 +70,188 @@ | |||
70 | 70 | ||
71 | #ifdef OPENSSL_NO_BIO | 71 | #ifdef OPENSSL_NO_BIO |
72 | 72 | ||
73 | void lh_stats(LHASH *lh, FILE *out) | 73 | void |
74 | { | 74 | lh_stats(LHASH *lh, FILE *out) |
75 | fprintf(out,"num_items = %lu\n",lh->num_items); | 75 | { |
76 | fprintf(out,"num_nodes = %u\n",lh->num_nodes); | 76 | fprintf(out, "num_items = %lu\n", lh->num_items); |
77 | fprintf(out,"num_alloc_nodes = %u\n",lh->num_alloc_nodes); | 77 | fprintf(out, "num_nodes = %u\n", lh->num_nodes); |
78 | fprintf(out,"num_expands = %lu\n",lh->num_expands); | 78 | fprintf(out, "num_alloc_nodes = %u\n", lh->num_alloc_nodes); |
79 | fprintf(out,"num_expand_reallocs = %lu\n",lh->num_expand_reallocs); | 79 | fprintf(out, "num_expands = %lu\n", lh->num_expands); |
80 | fprintf(out,"num_contracts = %lu\n",lh->num_contracts); | 80 | fprintf(out, "num_expand_reallocs = %lu\n", lh->num_expand_reallocs); |
81 | fprintf(out,"num_contract_reallocs = %lu\n",lh->num_contract_reallocs); | 81 | fprintf(out, "num_contracts = %lu\n", lh->num_contracts); |
82 | fprintf(out,"num_hash_calls = %lu\n",lh->num_hash_calls); | 82 | fprintf(out, "num_contract_reallocs = %lu\n", |
83 | fprintf(out,"num_comp_calls = %lu\n",lh->num_comp_calls); | 83 | lh->num_contract_reallocs); |
84 | fprintf(out,"num_insert = %lu\n",lh->num_insert); | 84 | fprintf(out, "num_hash_calls = %lu\n", lh->num_hash_calls); |
85 | fprintf(out,"num_replace = %lu\n",lh->num_replace); | 85 | fprintf(out, "num_comp_calls = %lu\n", lh->num_comp_calls); |
86 | fprintf(out,"num_delete = %lu\n",lh->num_delete); | 86 | fprintf(out, "num_insert = %lu\n", lh->num_insert); |
87 | fprintf(out,"num_no_delete = %lu\n",lh->num_no_delete); | 87 | fprintf(out, "num_replace = %lu\n", lh->num_replace); |
88 | fprintf(out,"num_retrieve = %lu\n",lh->num_retrieve); | 88 | fprintf(out, "num_delete = %lu\n", lh->num_delete); |
89 | fprintf(out,"num_retrieve_miss = %lu\n",lh->num_retrieve_miss); | 89 | fprintf(out, "num_no_delete = %lu\n", lh->num_no_delete); |
90 | fprintf(out,"num_hash_comps = %lu\n",lh->num_hash_comps); | 90 | fprintf(out, "num_retrieve = %lu\n", lh->num_retrieve); |
91 | fprintf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss); | ||
92 | fprintf(out, "num_hash_comps = %lu\n", lh->num_hash_comps); | ||
91 | #if 0 | 93 | #if 0 |
92 | fprintf(out,"p = %u\n",lh->p); | 94 | fprintf(out, "p = %u\n", lh->p); |
93 | fprintf(out,"pmax = %u\n",lh->pmax); | 95 | fprintf(out, "pmax = %u\n", lh->pmax); |
94 | fprintf(out,"up_load = %lu\n",lh->up_load); | 96 | fprintf(out, "up_load = %lu\n", lh->up_load); |
95 | fprintf(out,"down_load = %lu\n",lh->down_load); | 97 | fprintf(out, "down_load = %lu\n", lh->down_load); |
96 | #endif | 98 | #endif |
97 | } | 99 | } |
98 | 100 | ||
99 | void lh_node_stats(LHASH *lh, FILE *out) | 101 | void |
100 | { | 102 | lh_node_stats(LHASH *lh, FILE *out) |
103 | { | ||
101 | LHASH_NODE *n; | 104 | LHASH_NODE *n; |
102 | unsigned int i,num; | 105 | unsigned int i, num; |
103 | 106 | ||
104 | for (i=0; i<lh->num_nodes; i++) | 107 | for (i = 0; i < lh->num_nodes; i++) { |
105 | { | 108 | for (n = lh->b[i], num = 0; n != NULL; n = n->next) |
106 | for (n=lh->b[i],num=0; n != NULL; n=n->next) | ||
107 | num++; | 109 | num++; |
108 | fprintf(out,"node %6u -> %3u\n",i,num); | 110 | fprintf(out, "node %6u -> %3u\n", i, num); |
109 | } | ||
110 | } | 111 | } |
112 | } | ||
111 | 113 | ||
112 | void lh_node_usage_stats(LHASH *lh, FILE *out) | 114 | void |
113 | { | 115 | lh_node_usage_stats(LHASH *lh, FILE *out) |
116 | { | ||
114 | LHASH_NODE *n; | 117 | LHASH_NODE *n; |
115 | unsigned long num; | 118 | unsigned long num; |
116 | unsigned int i; | 119 | unsigned int i; |
117 | unsigned long total=0,n_used=0; | 120 | unsigned long total = 0, n_used = 0; |
118 | 121 | ||
119 | for (i=0; i<lh->num_nodes; i++) | 122 | for (i = 0; i < lh->num_nodes; i++) { |
120 | { | 123 | for (n = lh->b[i], num = 0; n != NULL; n = n->next) |
121 | for (n=lh->b[i],num=0; n != NULL; n=n->next) | ||
122 | num++; | 124 | num++; |
123 | if (num != 0) | 125 | if (num != 0) { |
124 | { | ||
125 | n_used++; | 126 | n_used++; |
126 | total+=num; | 127 | total += num; |
127 | } | ||
128 | } | 128 | } |
129 | fprintf(out,"%lu nodes used out of %u\n",n_used,lh->num_nodes); | ||
130 | fprintf(out,"%lu items\n",total); | ||
131 | if (n_used == 0) return; | ||
132 | fprintf(out,"load %d.%02d actual load %d.%02d\n", | ||
133 | (int)(total/lh->num_nodes), | ||
134 | (int)((total%lh->num_nodes)*100/lh->num_nodes), | ||
135 | (int)(total/n_used), | ||
136 | (int)((total%n_used)*100/n_used)); | ||
137 | } | 129 | } |
130 | fprintf(out, "%lu nodes used out of %u\n", n_used, lh->num_nodes); | ||
131 | fprintf(out, "%lu items\n", total); | ||
132 | if (n_used == 0) | ||
133 | return; | ||
134 | fprintf(out, "load %d.%02d actual load %d.%02d\n", | ||
135 | (int)(total / lh->num_nodes), | ||
136 | (int)((total % lh->num_nodes) * 100 / lh->num_nodes), | ||
137 | (int)(total / n_used), | ||
138 | (int)((total % n_used) * 100 / n_used)); | ||
139 | } | ||
138 | 140 | ||
139 | #else | 141 | #else |
140 | 142 | ||
141 | #ifndef OPENSSL_NO_FP_API | 143 | #ifndef OPENSSL_NO_FP_API |
142 | void lh_stats(const _LHASH *lh, FILE *fp) | 144 | void |
143 | { | 145 | lh_stats(const _LHASH *lh, FILE *fp) |
146 | { | ||
144 | BIO *bp; | 147 | BIO *bp; |
145 | 148 | ||
146 | bp=BIO_new(BIO_s_file()); | 149 | bp = BIO_new(BIO_s_file()); |
147 | if (bp == NULL) goto end; | 150 | if (bp == NULL) |
148 | BIO_set_fp(bp,fp,BIO_NOCLOSE); | 151 | goto end; |
149 | lh_stats_bio(lh,bp); | 152 | BIO_set_fp(bp, fp, BIO_NOCLOSE); |
153 | lh_stats_bio(lh, bp); | ||
150 | BIO_free(bp); | 154 | BIO_free(bp); |
151 | end:; | 155 | end:; |
152 | } | 156 | } |
153 | 157 | ||
154 | void lh_node_stats(const _LHASH *lh, FILE *fp) | 158 | void |
155 | { | 159 | lh_node_stats(const _LHASH *lh, FILE *fp) |
160 | { | ||
156 | BIO *bp; | 161 | BIO *bp; |
157 | 162 | ||
158 | bp=BIO_new(BIO_s_file()); | 163 | bp = BIO_new(BIO_s_file()); |
159 | if (bp == NULL) goto end; | 164 | if (bp == NULL) |
160 | BIO_set_fp(bp,fp,BIO_NOCLOSE); | 165 | goto end; |
161 | lh_node_stats_bio(lh,bp); | 166 | BIO_set_fp(bp, fp, BIO_NOCLOSE); |
167 | lh_node_stats_bio(lh, bp); | ||
162 | BIO_free(bp); | 168 | BIO_free(bp); |
163 | end:; | 169 | end:; |
164 | } | 170 | } |
165 | 171 | ||
166 | void lh_node_usage_stats(const _LHASH *lh, FILE *fp) | 172 | void |
167 | { | 173 | lh_node_usage_stats(const _LHASH *lh, FILE *fp) |
174 | { | ||
168 | BIO *bp; | 175 | BIO *bp; |
169 | 176 | ||
170 | bp=BIO_new(BIO_s_file()); | 177 | bp = BIO_new(BIO_s_file()); |
171 | if (bp == NULL) goto end; | 178 | if (bp == NULL) |
172 | BIO_set_fp(bp,fp,BIO_NOCLOSE); | 179 | goto end; |
173 | lh_node_usage_stats_bio(lh,bp); | 180 | BIO_set_fp(bp, fp, BIO_NOCLOSE); |
181 | lh_node_usage_stats_bio(lh, bp); | ||
174 | BIO_free(bp); | 182 | BIO_free(bp); |
175 | end:; | 183 | end:; |
176 | } | 184 | } |
177 | 185 | ||
178 | #endif | 186 | #endif |
179 | 187 | ||
180 | void lh_stats_bio(const _LHASH *lh, BIO *out) | 188 | void |
181 | { | 189 | lh_stats_bio(const _LHASH *lh, BIO *out) |
182 | BIO_printf(out,"num_items = %lu\n",lh->num_items); | 190 | { |
183 | BIO_printf(out,"num_nodes = %u\n",lh->num_nodes); | 191 | BIO_printf(out, "num_items = %lu\n", lh->num_items); |
184 | BIO_printf(out,"num_alloc_nodes = %u\n",lh->num_alloc_nodes); | 192 | BIO_printf(out, "num_nodes = %u\n", lh->num_nodes); |
185 | BIO_printf(out,"num_expands = %lu\n",lh->num_expands); | 193 | BIO_printf(out, "num_alloc_nodes = %u\n", lh->num_alloc_nodes); |
186 | BIO_printf(out,"num_expand_reallocs = %lu\n", | 194 | BIO_printf(out, "num_expands = %lu\n", lh->num_expands); |
187 | lh->num_expand_reallocs); | 195 | BIO_printf(out, "num_expand_reallocs = %lu\n", |
188 | BIO_printf(out,"num_contracts = %lu\n",lh->num_contracts); | 196 | lh->num_expand_reallocs); |
189 | BIO_printf(out,"num_contract_reallocs = %lu\n", | 197 | BIO_printf(out, "num_contracts = %lu\n", lh->num_contracts); |
190 | lh->num_contract_reallocs); | 198 | BIO_printf(out, "num_contract_reallocs = %lu\n", |
191 | BIO_printf(out,"num_hash_calls = %lu\n",lh->num_hash_calls); | 199 | lh->num_contract_reallocs); |
192 | BIO_printf(out,"num_comp_calls = %lu\n",lh->num_comp_calls); | 200 | BIO_printf(out, "num_hash_calls = %lu\n", lh->num_hash_calls); |
193 | BIO_printf(out,"num_insert = %lu\n",lh->num_insert); | 201 | BIO_printf(out, "num_comp_calls = %lu\n", lh->num_comp_calls); |
194 | BIO_printf(out,"num_replace = %lu\n",lh->num_replace); | 202 | BIO_printf(out, "num_insert = %lu\n", lh->num_insert); |
195 | BIO_printf(out,"num_delete = %lu\n",lh->num_delete); | 203 | BIO_printf(out, "num_replace = %lu\n", lh->num_replace); |
196 | BIO_printf(out,"num_no_delete = %lu\n",lh->num_no_delete); | 204 | BIO_printf(out, "num_delete = %lu\n", lh->num_delete); |
197 | BIO_printf(out,"num_retrieve = %lu\n",lh->num_retrieve); | 205 | BIO_printf(out, "num_no_delete = %lu\n", lh->num_no_delete); |
198 | BIO_printf(out,"num_retrieve_miss = %lu\n",lh->num_retrieve_miss); | 206 | BIO_printf(out, "num_retrieve = %lu\n", lh->num_retrieve); |
199 | BIO_printf(out,"num_hash_comps = %lu\n",lh->num_hash_comps); | 207 | BIO_printf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss); |
208 | BIO_printf(out, "num_hash_comps = %lu\n", lh->num_hash_comps); | ||
200 | #if 0 | 209 | #if 0 |
201 | BIO_printf(out,"p = %u\n",lh->p); | 210 | BIO_printf(out, "p = %u\n", lh->p); |
202 | BIO_printf(out,"pmax = %u\n",lh->pmax); | 211 | BIO_printf(out, "pmax = %u\n", lh->pmax); |
203 | BIO_printf(out,"up_load = %lu\n",lh->up_load); | 212 | BIO_printf(out, "up_load = %lu\n", lh->up_load); |
204 | BIO_printf(out,"down_load = %lu\n",lh->down_load); | 213 | BIO_printf(out, "down_load = %lu\n", lh->down_load); |
205 | #endif | 214 | #endif |
206 | } | 215 | } |
207 | 216 | ||
208 | void lh_node_stats_bio(const _LHASH *lh, BIO *out) | 217 | void |
209 | { | 218 | lh_node_stats_bio(const _LHASH *lh, BIO *out) |
219 | { | ||
210 | LHASH_NODE *n; | 220 | LHASH_NODE *n; |
211 | unsigned int i,num; | 221 | unsigned int i, num; |
212 | 222 | ||
213 | for (i=0; i<lh->num_nodes; i++) | 223 | for (i = 0; i < lh->num_nodes; i++) { |
214 | { | 224 | for (n = lh->b[i], num = 0; n != NULL; n = n->next) |
215 | for (n=lh->b[i],num=0; n != NULL; n=n->next) | ||
216 | num++; | 225 | num++; |
217 | BIO_printf(out,"node %6u -> %3u\n",i,num); | 226 | BIO_printf(out, "node %6u -> %3u\n", i, num); |
218 | } | ||
219 | } | 227 | } |
228 | } | ||
220 | 229 | ||
221 | void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out) | 230 | void |
222 | { | 231 | lh_node_usage_stats_bio(const _LHASH *lh, BIO *out) |
232 | { | ||
223 | LHASH_NODE *n; | 233 | LHASH_NODE *n; |
224 | unsigned long num; | 234 | unsigned long num; |
225 | unsigned int i; | 235 | unsigned int i; |
226 | unsigned long total=0,n_used=0; | 236 | unsigned long total = 0, n_used = 0; |
227 | 237 | ||
228 | for (i=0; i<lh->num_nodes; i++) | 238 | for (i = 0; i < lh->num_nodes; i++) { |
229 | { | 239 | for (n = lh->b[i], num = 0; n != NULL; n = n->next) |
230 | for (n=lh->b[i],num=0; n != NULL; n=n->next) | ||
231 | num++; | 240 | num++; |
232 | if (num != 0) | 241 | if (num != 0) { |
233 | { | ||
234 | n_used++; | 242 | n_used++; |
235 | total+=num; | 243 | total += num; |
236 | } | ||
237 | } | 244 | } |
238 | BIO_printf(out,"%lu nodes used out of %u\n",n_used,lh->num_nodes); | ||
239 | BIO_printf(out,"%lu items\n",total); | ||
240 | if (n_used == 0) return; | ||
241 | BIO_printf(out,"load %d.%02d actual load %d.%02d\n", | ||
242 | (int)(total/lh->num_nodes), | ||
243 | (int)((total%lh->num_nodes)*100/lh->num_nodes), | ||
244 | (int)(total/n_used), | ||
245 | (int)((total%n_used)*100/n_used)); | ||
246 | } | 245 | } |
246 | BIO_printf(out, "%lu nodes used out of %u\n", n_used, lh->num_nodes); | ||
247 | BIO_printf(out, "%lu items\n", total); | ||
248 | if (n_used == 0) | ||
249 | return; | ||
250 | BIO_printf(out, "load %d.%02d actual load %d.%02d\n", | ||
251 | (int)(total / lh->num_nodes), | ||
252 | (int)((total % lh->num_nodes) * 100 / lh->num_nodes), | ||
253 | (int)(total / n_used), | ||
254 | (int)((total % n_used) * 100 / n_used)); | ||
255 | } | ||
247 | 256 | ||
248 | #endif | 257 | #endif |