]>
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 | struct perf start, stop; | |
57 | ||
58 | create_data(inbuf, TEST_LEN); | |
224ce89b | 59 | printf("Window Size: %d K\n", IGZIP_HIST_SIZE / 1024); |
7c673cae FG |
60 | printf("igzip_sync_flush_perf: \n"); |
61 | fflush(0); | |
62 | ||
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 | if (i == (TEST_LOOPS - 1)) | |
70 | stream.end_of_stream = 1; | |
71 | else | |
72 | stream.end_of_stream = 0; | |
73 | stream.next_in = inbuf; | |
74 | stream.flush = SYNC_FLUSH; | |
75 | ||
76 | do { | |
77 | stream.avail_out = OBUF_SIZE; | |
78 | stream.next_out = zbuf; | |
79 | isal_deflate(&stream); | |
80 | } while (stream.avail_out == 0); | |
81 | ||
82 | } | |
83 | ||
84 | perf_stop(&stop); | |
85 | ||
86 | printf("igzip_sync_flush_perf" TEST_TYPE_STR ": "); | |
87 | perf_print(stop, start, (long long)(TEST_LEN) * (i)); | |
88 | ||
89 | if (!stream.end_of_stream) { | |
90 | printf("error: compression test could not fit into allocated buffers\n"); | |
91 | return -1; | |
92 | } | |
93 | printf("End of igzip_sync_flush_perf\n\n"); | |
94 | fflush(0); | |
95 | return 0; | |
96 | } |