/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: #ident "$Id$" /*====== This file is part of PerconaFT. Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. PerconaFT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. PerconaFT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with PerconaFT. If not, see . ---------------------------------------- PerconaFT is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation. PerconaFT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with PerconaFT. If not, see . ======= */ #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." // Test zlib, lzma, quicklz, and snappy. // Compare to compress-test which tests the toku compression (which is a composite of quicklz and zlib). #include #include "test.h" #include "serialize/compress.h" static float tdiff (struct timeval *start, struct timeval *end) { return (end->tv_sec-start->tv_sec) + 1e-6*(end->tv_usec - start->tv_usec); } static uLongf test_compress_buf_method (unsigned char *buf, int i, enum toku_compression_method m) { int bound = toku_compress_bound(m, i); unsigned char *MALLOC_N(bound, cb); uLongf actual_clen = bound; toku_compress(m, cb, &actual_clen, buf, i); unsigned char *MALLOC_N(i, ubuf); toku_decompress(ubuf, i, cb, actual_clen); assert(0==memcmp(ubuf, buf, i)); toku_free(ubuf); toku_free(cb); return actual_clen; } static void test_compress_i (int i, enum toku_compression_method m, uLongf *compress_size, uLongf *uncompress_size) { unsigned char *MALLOC_N(i, b); for (int j=0; j