22 #include <lzo/lzo1x.h>
28 #define MAXSZ (10*1024*1024)
32 #define BENCHMARK_LIBLZO_SAFE 0
33 #define BENCHMARK_LIBLZO_UNSAFE 0
35 int main(
int argc,
char *argv[]) {
36 FILE *in = fopen(argv[1],
"rb");
37 int comp_level = argc > 2 ? atoi(argv[2]) : 0;
41 size_t s = fread(orig, 1,
MAXSZ, in);
43 long tmp[LZO1X_MEM_COMPRESS];
47 if (comp_level == 0) {
48 lzo1x_1_compress(orig,
s,
comp, &clen,
tmp);
49 }
else if (comp_level == 11) {
50 lzo1x_1_11_compress(orig,
s,
comp, &clen,
tmp);
51 }
else if (comp_level == 12) {
52 lzo1x_1_12_compress(orig,
s,
comp, &clen,
tmp);
53 }
else if (comp_level == 15) {
54 lzo1x_1_15_compress(orig,
s,
comp, &clen,
tmp);
56 lzo1x_999_compress(orig,
s,
comp, &clen,
tmp);
57 for (
i = 0;
i < 300;
i++) {
58 inlen = clen; outlen =
MAXSZ;
59 #if BENCHMARK_LIBLZO_SAFE
60 if (lzo1x_decompress_safe(
comp, inlen, decomp, &outlen,
NULL))
61 #elif BENCHMARK_LIBLZO_UNSAFE
62 if (lzo1x_decompress(
comp, inlen, decomp, &outlen,
NULL))
68 if (memcmp(orig, decomp,
s))