From d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb Mon Sep 17 00:00:00 2001 From: ng0 Date: Sun, 8 Sep 2019 12:33:09 +0000 Subject: uncrustify as demanded. --- src/set/ibf_sim.c | 119 +++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 59 deletions(-) (limited to 'src/set/ibf_sim.c') diff --git a/src/set/ibf_sim.c b/src/set/ibf_sim.c index d05e06188..02b675f4a 100644 --- a/src/set/ibf_sim.c +++ b/src/set/ibf_sim.c @@ -11,12 +11,12 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . SPDX-License-Identifier: AGPL3.0-or-later -*/ + */ /** * @file set/ibf_sim.c @@ -62,76 +62,77 @@ main(int argc, char **argv) unsigned int want; double predict; - srandom (time (NULL)); + srandom(time(NULL)); total = 0; - want = atoi (argv[1]); - for (round=0;round= 0; j--) - { + buckets[j]++; + } + ret = 0; + predict = 0.0; + for (j = 31; j >= 0; j--) + { #if FIX1 - /* improved algorithm, for 1000 elements with IBF-DECODE 8, I - get 990/1000 elements on average over 1 million runs; key - idea being to stop short of the 'last' possible IBF as - otherwise a "lowball" per-chance would unduely influence the - result */ - if ( (j > 0) && - (buckets[j - 1] > MAX_IBF_DECODE) ) - { - ret *= (1 << (j + 1)); - break; - } + /* improved algorithm, for 1000 elements with IBF-DECODE 8, I + get 990/1000 elements on average over 1 million runs; key + idea being to stop short of the 'last' possible IBF as + otherwise a "lowball" per-chance would unduely influence the + result */ + if ((j > 0) && + (buckets[j - 1] > MAX_IBF_DECODE)) + { + ret *= (1 << (j + 1)); + break; + } #endif #if FIX2 - /* another improvement: don't just always cut off the last one, - but rather try to predict based on all previous values where - that "last" one is; additional prediction can only really - work if MAX_IBF_DECODE is sufficiently high */ - if ( (j > 0) && - ( (buckets[j - 1] > MAX_IBF_DECODE) || - (predict > MAX_IBF_DECODE) ) ) - { - ret *= (1 << (j + 1)); - break; - } + /* another improvement: don't just always cut off the last one, + but rather try to predict based on all previous values where + that "last" one is; additional prediction can only really + work if MAX_IBF_DECODE is sufficiently high */ + if ((j > 0) && + ((buckets[j - 1] > MAX_IBF_DECODE) || + (predict > MAX_IBF_DECODE))) + { + ret *= (1 << (j + 1)); + break; + } #endif #if STRATA - /* original algorithm, for 1000 elements with IBF-DECODE 8, - I get 920/1000 elements on average over 1 million runs */ - if (buckets[j] > MAX_IBF_DECODE) - { - ret *= (1 << (j+1)); - break; - } + /* original algorithm, for 1000 elements with IBF-DECODE 8, + I get 920/1000 elements on average over 1 million runs */ + if (buckets[j] > MAX_IBF_DECODE) + { + ret *= (1 << (j + 1)); + break; + } #endif - ret += buckets[j]; - predict = (buckets[j] + 2.0 * predict) / 2.0; - } + ret += buckets[j]; + predict = (buckets[j] + 2.0 * predict) / 2.0; + } #if VERBOSE - fprintf (stderr, "%u ", ret); + fprintf(stderr, "%u ", ret); #endif - total += ret; - } - fprintf (stderr, "\n"); - fprintf (stdout, "average %llu\n", total / ROUNDS); + total += ret; + } + fprintf(stderr, "\n"); + fprintf(stdout, "average %llu\n", total / ROUNDS); return 0; } -- cgit v1.2.3