]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | /********************************************************************** |
f91f0fd5 | 2 | Copyright(c) 2011-2017 Intel Corporation All rights reserved. |
7c673cae FG |
3 | |
4 | Redistribution and use in source and binary forms, with or without | |
f91f0fd5 | 5 | modification, are permitted provided that the following conditions |
7c673cae FG |
6 | are met: |
7 | * Redistributions of source code must retain the above copyright | |
8 | notice, this list of conditions and the following disclaimer. | |
9 | * Redistributions in binary form must reproduce the above copyright | |
10 | notice, this list of conditions and the following disclaimer in | |
11 | the documentation and/or other materials provided with the | |
12 | distribution. | |
13 | * Neither the name of Intel Corporation nor the names of its | |
14 | contributors may be used to endorse or promote products derived | |
15 | from this software without specific prior written permission. | |
16 | ||
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | **********************************************************************/ | |
29 | ||
30 | #include <stdio.h> | |
31 | #include <stdlib.h> | |
f91f0fd5 TL |
32 | #include <string.h> |
33 | #include <stdint.h> | |
34 | #include <sys/time.h> | |
35 | #include "crc.h" | |
7c673cae FG |
36 | #include "test.h" |
37 | ||
38 | //#define CACHED_TEST | |
39 | #ifdef CACHED_TEST | |
40 | // Cached test, loop many times over small dataset | |
41 | # define TEST_LEN 8*1024 | |
7c673cae FG |
42 | # define TEST_TYPE_STR "_warm" |
43 | #else | |
7c673cae | 44 | // Uncached test. Pull from large mem base. |
7c673cae | 45 | # define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ |
f91f0fd5 | 46 | # define TEST_LEN (2 * GT_L3_CACHE) |
7c673cae | 47 | # define TEST_TYPE_STR "_cold" |
7c673cae FG |
48 | #endif |
49 | ||
f91f0fd5 TL |
50 | #ifndef TEST_SEED |
51 | # define TEST_SEED 0x1234 | |
52 | #endif | |
7c673cae | 53 | |
f91f0fd5 | 54 | #define TEST_MEM TEST_LEN |
7c673cae FG |
55 | |
56 | int main(int argc, char *argv[]) | |
57 | { | |
f91f0fd5 TL |
58 | void *buf; |
59 | uint32_t crc; | |
60 | struct perf start; | |
7c673cae | 61 | |
f91f0fd5 | 62 | printf("crc32_gzip_refl_perf:\n"); |
7c673cae | 63 | |
f91f0fd5 TL |
64 | if (posix_memalign(&buf, 1024, TEST_LEN)) { |
65 | printf("alloc error: Fail"); | |
66 | return -1; | |
7c673cae FG |
67 | } |
68 | ||
f91f0fd5 TL |
69 | printf("Start timed tests\n"); |
70 | fflush(0); | |
71 | ||
72 | memset(buf, 0, TEST_LEN); | |
73 | BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_gzip_refl(TEST_SEED, buf, TEST_LEN)); | |
74 | printf("crc32_gzip_refl" TEST_TYPE_STR ": "); | |
75 | perf_print(start, (long long)TEST_LEN); | |
76 | ||
77 | printf("finish 0x%x\n", crc); | |
7c673cae | 78 | |
f91f0fd5 | 79 | printf("crc32_gzip_refl_base_perf:\n"); |
7c673cae FG |
80 | printf("Start timed tests\n"); |
81 | fflush(0); | |
82 | ||
f91f0fd5 TL |
83 | BENCHMARK(&start, BENCHMARK_TIME, crc = |
84 | crc32_gzip_refl_base(TEST_SEED, buf, TEST_LEN)); | |
85 | printf("crc32_gzip_refl_base" TEST_TYPE_STR ": "); | |
86 | perf_print(start, (long long)TEST_LEN); | |
87 | ||
88 | printf("finish 0x%x\n", crc); | |
7c673cae FG |
89 | |
90 | return 0; | |
91 | } |