"Fossies" - the Fresh Open Source Software Archive

Member "xxHash-0.8.0/tests/bench/benchHash.h" (27 Jul 2020, 2015 Bytes) of package /linux/misc/xxHash-0.8.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "benchHash.h": 0.7.3_vs_0.7.4.

    1 /*
    2 *  Hash benchmark module
    3 *  Part of the xxHash project
    4 *  Copyright (C) 2019-2020 Yann Collet
    5 *
    6 *  GPL v2 License
    7 *
    8 *  This program is free software; you can redistribute it and/or modify
    9 *  it under the terms of the GNU General Public License as published by
   10 *  the Free Software Foundation; either version 2 of the License, or
   11 *  (at your option) any later version.
   12 *
   13 *  This program is distributed in the hope that it will be useful,
   14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16 *  GNU General Public License for more details.
   17 *
   18 *  You should have received a copy of the GNU General Public License along
   19 *  with this program; if not, write to the Free Software Foundation, Inc.,
   20 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   21 *
   22 *  You can contact the author at:
   23 *  - xxHash homepage: https://www.xxhash.com
   24 *  - xxHash source repository: https://github.com/Cyan4973/xxHash
   25 */
   26 
   27 
   28 #ifndef BENCH_HASH_H_983426678
   29 #define BENCH_HASH_H_983426678
   30 
   31 #if defined (__cplusplus)
   32 extern "C" {
   33 #endif
   34 
   35 
   36 /* ===  Dependencies  === */
   37 
   38 #include "benchfn.h"   /* BMK_benchFn_t */
   39 
   40 
   41 /* ===  Declarations  === */
   42 
   43 typedef enum { BMK_throughput, BMK_latency } BMK_benchMode;
   44 
   45 typedef enum { BMK_fixedSize,   /* hash always `size` bytes */
   46                BMK_randomSize,  /* hash a random nb of bytes, between 1 and `size` (inclusive) */
   47 } BMK_sizeMode;
   48 
   49 /*
   50  * bench_hash():
   51  * Returns speed expressed as nb hashes per second.
   52  * total_time_ms: time spent benchmarking the hash function with given parameters
   53  * iter_time_ms: time spent for one round. If multiple rounds are run,
   54  *               bench_hash() will report the speed of best round.
   55  */
   56 double bench_hash(BMK_benchFn_t hashfn,
   57                   BMK_benchMode benchMode,
   58                   size_t size, BMK_sizeMode sizeMode,
   59                   unsigned total_time_ms, unsigned iter_time_ms);
   60 
   61 
   62 
   63 #if defined (__cplusplus)
   64 }
   65 #endif
   66 
   67 #endif /* BENCH_HASH_H_983426678 */