OpenCoverage

lh_stats.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/lhash/lh_stats.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#include <stdio.h>-
11#include <string.h>-
12#include <stdlib.h>-
13/*-
14 * If you wish to build this outside of OpenSSL, remove the following lines-
15 * and things should work as expected-
16 */-
17#include "internal/cryptlib.h"-
18-
19#include <openssl/bio.h>-
20#include <openssl/lhash.h>-
21#include "lhash_lcl.h"-
22-
23# ifndef OPENSSL_NO_STDIO-
24void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp)-
25{-
26 BIO *bp;-
27-
28 bp = BIO_new(BIO_s_file());-
29 if (bp == NULL)
bp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
30 return;
never executed: return;
0
31 BIO_set_fp(bp, fp, BIO_NOCLOSE);-
32 OPENSSL_LH_stats_bio(lh, bp);-
33 BIO_free(bp);-
34}
never executed: end of block
0
35-
36void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp)-
37{-
38 BIO *bp;-
39-
40 bp = BIO_new(BIO_s_file());-
41 if (bp == NULL)
bp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
42 return;
never executed: return;
0
43 BIO_set_fp(bp, fp, BIO_NOCLOSE);-
44 OPENSSL_LH_node_stats_bio(lh, bp);-
45 BIO_free(bp);-
46}
never executed: end of block
0
47-
48void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp)-
49{-
50 BIO *bp;-
51-
52 bp = BIO_new(BIO_s_file());-
53 if (bp == NULL)
bp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
54 return;
never executed: return;
0
55 BIO_set_fp(bp, fp, BIO_NOCLOSE);-
56 OPENSSL_LH_node_usage_stats_bio(lh, bp);-
57 BIO_free(bp);-
58}
never executed: end of block
0
59-
60# endif-
61-
62void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out)-
63{-
64 BIO_printf(out, "num_items = %lu\n", lh->num_items);-
65 BIO_printf(out, "num_nodes = %u\n", lh->num_nodes);-
66 BIO_printf(out, "num_alloc_nodes = %u\n", lh->num_alloc_nodes);-
67 BIO_printf(out, "num_expands = %lu\n", lh->num_expands);-
68 BIO_printf(out, "num_expand_reallocs = %lu\n", lh->num_expand_reallocs);-
69 BIO_printf(out, "num_contracts = %lu\n", lh->num_contracts);-
70 BIO_printf(out, "num_contract_reallocs = %lu\n", lh->num_contract_reallocs);-
71 BIO_printf(out, "num_hash_calls = %lu\n", lh->num_hash_calls);-
72 BIO_printf(out, "num_comp_calls = %lu\n", lh->num_comp_calls);-
73 BIO_printf(out, "num_insert = %lu\n", lh->num_insert);-
74 BIO_printf(out, "num_replace = %lu\n", lh->num_replace);-
75 BIO_printf(out, "num_delete = %lu\n", lh->num_delete);-
76 BIO_printf(out, "num_no_delete = %lu\n", lh->num_no_delete);-
77 BIO_printf(out, "num_retrieve = %lu\n", lh->num_retrieve);-
78 BIO_printf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss);-
79 BIO_printf(out, "num_hash_comps = %lu\n", lh->num_hash_comps);-
80}
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
81-
82void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out)-
83{-
84 OPENSSL_LH_NODE *n;-
85 unsigned int i, num;-
86-
87 for (i = 0; i < lh->num_nodes; i++) {
i < lh->num_nodesDescription
TRUEnever evaluated
FALSEnever evaluated
0
88 for (n = lh->b[i], num = 0; n != NULL; n = n->next)
n != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
89 num++;
never executed: num++;
0
90 BIO_printf(out, "node %6u -> %3u\n", i, num);-
91 }
never executed: end of block
0
92}
never executed: end of block
0
93-
94void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out)-
95{-
96 OPENSSL_LH_NODE *n;-
97 unsigned long num;-
98 unsigned int i;-
99 unsigned long total = 0, n_used = 0;-
100-
101 for (i = 0; i < lh->num_nodes; i++) {
i < lh->num_nodesDescription
TRUEevaluated 1250016 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-1250016
102 for (n = lh->b[i], num = 0; n != NULL; n = n->next)
n != ((void *)0)Description
TRUEevaluated 2500000 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1250016 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1250016-2500000
103 num++;
executed 2500000 times by 1 test: num++;
Executed by:
  • libcrypto.so.1.1
2500000
104 if (num != 0) {
num != 0Description
TRUEevaluated 1250000 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16-1250000
105 n_used++;-
106 total += num;-
107 }
executed 1250000 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1250000
108 }
executed 1250016 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1250016
109 BIO_printf(out, "%lu nodes used out of %u\n", n_used, lh->num_nodes);-
110 BIO_printf(out, "%lu items\n", total);-
111 if (n_used == 0)
n_used == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1
112 return;
executed 1 time by 1 test: return;
Executed by:
  • libcrypto.so.1.1
1
113 BIO_printf(out, "load %d.%02d actual load %d.%02d\n",-
114 (int)(total / lh->num_nodes),-
115 (int)((total % lh->num_nodes) * 100 / lh->num_nodes),-
116 (int)(total / n_used), (int)((total % n_used) * 100 / n_used));-
117}
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2