23 int main(
int argc,
char** argv)
29 cerr <<
"Usage: test-compress <input_file> [compression level 1-9]" 34 std::vector<uint8_t> buf;
38 cerr <<
"Error loading file: " << argv[1] << endl;
42 string gzfile =
format(
"%s.gz", argv[1]);
43 int compress_level = 9;
46 compress_level = atoi(argv[2]);
54 cerr <<
"Error writing compressing file: " << gzfile << endl;
58 double t = tictac.
Tac();
60 "Compressed %s (compress level=%i) in %.04f seconds.",
61 gzfile.c_str(), compress_level,
t)
66 catch (std::exception& e)
68 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
73 printf(
"Untyped exception!!");
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).
void Tic() noexcept
Starts the stopwatch.