16#define BLOCK_SIZE 1500
34#define SUPPORT_SWAP false
55 const size_t headroom = 512;
56 const size_t tailroom = 512;
57 const size_t align_block = 16;
58 const unsigned int buffer_flags = 0;
75 void error(
const size_t err_type,
const std::string *text = NULL)
override
95 ASSERT_EQ(b1, b2) <<
"decompressed data doesn't match original data";
98void test(
const std::string &filename,
102 const size_t block_size,
103 const size_t n_compress,
104 const size_t n_expand_per_compress,
106 size_t &compress_bytes)
109 for (
size_t offset = 0; offset < source_data->size(); offset += block_size)
111 const size_t length = std::min(block_size, source_data->size() - offset);
114 data_seg.
write(source_data->data_raw() + offset, length);
115 for (
size_t compress_iter = 0; compress_iter < n_compress; ++compress_iter)
118 bytes += data1.
size();
120 compress_bytes += data1.
size();
121 if (n_expand_per_compress == 1)
128 for (
size_t decompress_iter = 0; decompress_iter < n_expand_per_compress; ++decompress_iter)
142 const size_t block_size,
143 const size_t n_compress,
144 const size_t n_expand_per_compress,
146 size_t &compress_bytes)
148 static const std::vector<std::string> filenames = {
149 "comp-testdata/alice29.txt",
150 "comp-testdata/asyoulik.txt",
151 "comp-testdata/cp.html",
152 "comp-testdata/fields.c",
153 "comp-testdata/geo.protodata",
154 "comp-testdata/grammar.lsp",
155 "comp-testdata/house.jpg",
156 "comp-testdata/html",
157 "comp-testdata/html_x_4",
158 "comp-testdata/kennedy.xls",
159 "comp-testdata/kppkn.gtb",
160 "comp-testdata/lcet10.txt",
161 "comp-testdata/mapreduce-osdi-1.pdf",
162 "comp-testdata/plrabn12.txt",
163 "comp-testdata/ptt5",
165 "comp-testdata/urls.10K",
166 "comp-testdata/xargs.1",
168 for (
const auto &fn : filenames)
170 test(std::string(UNITTEST_SOURCE_DIR) +
'/' + fn,
176 n_expand_per_compress,
210 decompress = compress;
217 decompress = compress;
220#if defined(HAVE_SNAPPY)
223 decompress = compress;
227 ASSERT_TRUE(
false) <<
"compressor/decompressor pair not supported";
230 size_t compress_bytes = 0;
234 std::cout <<
"comp=" << compress->name() <<
'[' <<
N_COMPRESS <<
']'
235 <<
" decomp=" << decompress->name() <<
'[' <<
N_EXPAND <<
']'
237 <<
" bytes=" << bytes
238 <<
" comp-bytes=" << compress_bytes
239 <<
" comp-ratio=" << (bytes ?
static_cast<float>(compress_bytes) /
static_cast<float>(bytes) : 0.0)
244#if defined(HAVE_SNAPPY)
void error(const size_t err_type, const std::string *text=NULL) override
count_t errors[Error::N_ERRORS]
count_t get_error_count(const Error::Type type) const
RCPtr< MySessionStats > Ptr
static void init_static()
virtual void decompress(BufferAllocated &buf)=0
virtual void compress(BufferAllocated &buf, const bool hint)=0
size_t size() const
Returns the size of the buffer in T objects.
void write(const T *data, const size_t size)
Write data to the buffer.
size_t prepare(const unsigned int context, Buffer &buf) const
void standardize_capacity(const unsigned int context_mask)
void reset() noexcept
Points this RCPtr<T> to nullptr safely.
Support deferred server-side state creation when client connects.
BufferPtr read_binary(const std::string &filename, const std::uint64_t max_size=0, const unsigned int buffer_flags=0)
Frame::Ptr frame_init(const bool align_adjust_3_1, const size_t tun_mtu_max, const size_t control_channel_payload, const bool verbose)
TEST(CPUTime, cpu_time_pid)
void test_with_corpus(Compress &compressor, Compress &decompressor, const Frame &frame, const size_t block_size, const size_t n_compress, const size_t n_expand_per_compress, size_t &bytes, size_t &compress_bytes)
void verify_eq(const Buffer &b1, const Buffer &b2)
void runTest(comppair alg, bool verbose=false)