lipsum-cpp 0.5.4
A basic library written in C++ for generating placeholder Lorem Ipsum text.
Loading...
Searching...
No Matches
CompressionBenchmarks.cpp
#ifndef LIPSUM_BUILD_STATIC
# define LIPSUM_IMPLEMENTATION // only for header-only usage
#endif
#include <lipsum.hpp>
#include <zlib.h>
int main()
{
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;
}
Main class of lipsum-cpp.
Definition generator.hpp:92
std::string fmt_text(int numElements=15, bool useHtml=false)
Generate a Markdown or HTML document.
Definition generatorformats.inl:53
Main header of lipsum-cpp.