@media only all and (prefers-color-scheme: dark) { .highlight .hll { background-color: #49483e } .highlight .c { color: #75715e } /* Comment */ .highlight .err { color: #960050; background-color: #1e0010 } /* Error */ .highlight .k { color: #66d9ef } /* Keyword */ .highlight .l { color: #ae81ff } /* Literal */ .highlight .n { color: #f8f8f2 } /* Name */ .highlight .o { color: #f92672 } /* Operator */ .highlight .p { color: #f8f8f2 } /* Punctuation */ .highlight .ch { color: #75715e } /* Comment.Hashbang */ .highlight .cm { color: #75715e } /* Comment.Multiline */ .highlight .cp { color: #75715e } /* Comment.Preproc */ .highlight .cpf { color: #75715e } /* Comment.PreprocFile */ .highlight .c1 { color: #75715e } /* Comment.Single */ .highlight .cs { color: #75715e } /* Comment.Special */ .highlight .gd { color: #f92672 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gi { color: #a6e22e } /* Generic.Inserted */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #75715e } /* Generic.Subheading */ .highlight .kc { color: #66d9ef } /* Keyword.Constant */ .highlight .kd { color: #66d9ef } /* Keyword.Declaration */ .highlight .kn { color: #f92672 } /* Keyword.Namespace */ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */ .highlight .kt { color: #66d9ef } /* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f
double-ring-nested.xenial
pf"><vppinfra/random.h> static int verbose; #define if_verbose(format,args...) \ if (verbose) { clib_warning(format, ## args); } int test_phash_main (unformat_input_t * input) { phash_main_t _pm = { 0 }, *pm = &_pm; int n_keys, random_keys; u32 seed; clib_error_t *error; random_keys = 1; n_keys = 1000; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (0 == unformat (input, "keys %d", &n_keys) && 0 == unformat (input, "verbose %=", &verbose, 1) && 0 == unformat (input, "random-keys %=", &random_keys, 1) && 0 == unformat (input, "sequential-keys %=", &random_keys, 0) && 0 == unformat (input, "seed %d", &pm->random_seed) && 0 == unformat (input, "64-bit %|", &pm->flags, PHASH_FLAG_MIX64) && 0 == unformat (input, "32-bit %|", &pm->flags, PHASH_FLAG_MIX32) && 0 == unformat (input, "fast %|", &pm->flags, PHASH_FLAG_FAST_MODE) && 0 == unformat (input, "slow %|", &pm->flags, PHASH_FLAG_SLOW_MODE) && 0 == unformat (input, "minimal %|", &pm->flags, PHASH_FLAG_MINIMAL) && 0 == unformat (input, "non-minimal %|", &pm->flags, PHASH_FLAG_NON_MINIMAL)) clib_error ("unknown input `%U'", format_unformat_error, input); } if (!pm->random_seed) pm->random_seed = random_default_seed (); if_verbose ("%d %d-bit keys, random seed %d, %s mode, looking for %sminimal hash", n_keys, (pm->flags & PHASH_FLAG_MIX64) ? 64 : 32, pm->random_seed, (pm->flags & PHASH_FLAG_FAST_MODE) ? "fast" : "slow", (pm->flags & PHASH_FLAG_MINIMAL) ? "" : "non-"); seed = pm->random_seed; /* Initialize random keys. */ { phash_key_t *k; vec_resize (pm->keys, n_keys); vec_foreach (k, pm->keys) { k->key = k - pm->keys; if (random_keys) { if (pm->flags & PHASH_FLAG_MIX64) k->key = random_u64 (&seed); else k->key = random_u32 (&seed); } } } error = phash_find_perfect_hash (pm); if (error) { clib_error_report (error); return 1; } else { if_verbose ("(%d,%d) (a,b) bits, %d seeds tried, %d tree walks", pm->a_bits, pm->b_bits, pm->n_seed_trials, pm->n_perfect_calls); error = phash_validate (pm); if (error) { clib_error_report (error); return 1; } } return 0; } #ifdef CLIB_UNIX int main (int argc, char *argv[]) { unformat_input_t i; int res; verbose = (argc > 1); unformat_init_command_line (&i, argv); res = test_phash_main (&i); unformat_free (&i); return res; } #endif /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */