-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompressionBenchmarks.cpp
More file actions
43 lines (39 loc) · 1.04 KB
/
Copy pathCompressionBenchmarks.cpp
File metadata and controls
43 lines (39 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef LIPSUM_BUILD_STATIC
# define LIPSUM_IMPLEMENTATION // only for header-only usage
#endif
#include <lipsum.hpp>
#include <zlib.h>
int main()
{
lpsm::Generator gen;
std::string text = gen.fmt_text(100000);
// std::string text;
// text.reserve(1000000);
// for(int i = 0; i < 1000; ++i)
//{
// text += "A";
// }
// std::cout << text << "\n\n";
uLong textLen = text.size();
uLong compLen = compressBound(textLen);
std::vector<unsigned char> comp(compLen);
if (compress(comp.data(),
&compLen,
reinterpret_cast<const Bytef*>(text.data()),
textLen) != Z_OK)
{
return -1;
}
while (comp.back() == 0)
{
comp.pop_back();
}
// for(const auto& letter : comp)
//{
// std::cout << letter;
// }
// std::cout << '\n';
std::cout << "Original size: " << text.size() << '\n';
std::cout << "Compressed size: " << comp.size() << '\n';
return 0;
}