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