24 int main(
int argc,
char** argv)
30 cerr <<
"Usage: test-compress <input_file> [compression level 1-9]" 35 std::vector<uint8_t> buf;
39 cerr <<
"Error loading file: " << argv[1] << endl;
43 string gzfile =
format(
"%s.gz", argv[1]);
44 int compress_level = 9;
47 compress_level = atoi(argv[2]);
55 cerr <<
"Error writing compressing file: " << gzfile << endl;
59 double t = tictac.
Tac();
61 "Compressed %s (compress level=%i) in %.04f seconds.",
62 gzfile.c_str(), compress_level,
t)
67 catch (
const std::exception& e)
double Tac() noexcept
Stops the stopwatch.
A high-performance stopwatch, with typical resolution of nanoseconds.
bool loadBinaryFile(std::vector< uint8_t > &out_data, const std::string &fileName)
Loads a entire file as a vector of bytes.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
bool compress_gz_file(const std::string &file_path, const std::vector< uint8_t > &buffer, const int compress_level=9)
Compress a memory buffer into a gzip file (xxxx.gz).
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
void Tic() noexcept
Starts the stopwatch.