]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /********************************************************************** |
2 | Copyright(c) 2011-2016 Intel Corporation All rights reserved. | |
3 | ||
4 | Redistribution and use in source and binary forms, with or without | |
5 | modification, are permitted provided that the following conditions | |
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> | |
32 | #include <string.h> | |
33 | #include <assert.h> | |
34 | #include "igzip_lib.h" | |
35 | #include "test.h" | |
36 | ||
37 | #define TEST_LEN (1024*1024) | |
38 | #define IBUF_SIZE (1024*1024) | |
39 | #define OBUF_SIZE (1024*1024) | |
40 | ||
41 | #define TEST_LOOPS 400 | |
42 | #define TEST_TYPE_STR "_warm" | |
43 | ||
44 | void create_data(unsigned char *data, int size) | |
45 | { | |
46 | char c = 'a'; | |
47 | while (size--) | |
48 | *data++ = c = c < 'z' ? c + 1 : 'a'; | |
49 | } | |
50 | ||
51 | int main(int argc, char *argv[]) | |
52 | { | |
53 | int i = 1; | |
54 | struct isal_zstream stream; | |
55 | unsigned char inbuf[IBUF_SIZE], zbuf[OBUF_SIZE]; | |
56 | ||
224ce89b | 57 | printf("Window Size: %d K\n", IGZIP_HIST_SIZE / 1024); |
7c673cae FG |
58 | printf("igzip_perf: \n"); |
59 | fflush(0); | |
60 | create_data(inbuf, TEST_LEN); | |
61 | ||
62 | struct perf start, stop; | |
63 | perf_start(&start); | |
64 | ||
65 | for (i = 0; i < TEST_LOOPS; i++) { | |
66 | isal_deflate_init(&stream); | |
67 | ||
68 | stream.avail_in = TEST_LEN; | |
69 | stream.end_of_stream = 1; | |
70 | stream.next_in = inbuf; | |
71 | stream.flush = NO_FLUSH; | |
72 | ||
73 | do { | |
74 | stream.avail_out = OBUF_SIZE; | |
75 | stream.next_out = zbuf; | |
76 | isal_deflate(&stream); | |
77 | } while (stream.avail_out == 0); | |
78 | } | |
79 | ||
80 | perf_stop(&stop); | |
81 | ||
82 | printf("igzip" TEST_TYPE_STR ": "); | |
83 | perf_print(stop, start, (long long)TEST_LEN * i); | |
84 | ||
85 | if (!stream.end_of_stream) { | |
86 | printf("error: compression test could not fit into allocated buffers\n"); | |
87 | return -1; | |
88 | } | |
89 | printf("End of igzip_perf\n\n"); | |
90 | fflush(0); | |
91 | return 0; | |
92 | } |