diff -rup lzip-1.23/main.cc lzip-1.23-dcspeed-2/main.cc --- lzip-1.23/main.cc 2022-01-22 00:11:01.000000000 +0000 +++ lzip-1.23-dcspeed-2/main.cc 2022-08-06 00:00:13.000000000 +0000 @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -558,6 +559,14 @@ bool next_filename() } +static long long clock_ns() + { + struct timespec time_now; + clock_gettime(CLOCK_MONOTONIC, &time_now); + return time_now.tv_sec*1e+9 + time_now.tv_nsec; + } + + int compress( const unsigned long long cfile_size, const unsigned long long member_size, const unsigned long long volume_size, const int infd, @@ -567,6 +576,8 @@ int compress( const unsigned long long c int retval = 0; LZ_encoder_base * encoder = 0; // polymorphic encoder if( verbosity >= 1 ) pp(); + long long time_start = clock_ns(); + long long time_end; if( zero ) encoder = new FLZ_encoder( infd, outfd ); @@ -615,12 +626,18 @@ int compress( const unsigned long long c if( in_size == 0 || out_size == 0 ) std::fputs( " no data compressed.\n", stderr ); else + { + time_end = clock_ns(); std::fprintf( stderr, "%6.3f:1, %5.2f%% ratio, %5.2f%% saved, " - "%llu in, %llu out.\n", + "%llu in, %llu out; in %0.2f[s]: %0.2f[MiB/s].\n", (double)in_size / out_size, ( 100.0 * out_size ) / in_size, 100.0 - ( ( 100.0 * out_size ) / in_size ), - in_size, out_size ); + in_size, + out_size, + (double)( time_end - time_start ) / 1e+9, + (in_size / ((double)( time_end - time_start ) / 1e+9 )) / (1024*1024) ); + } } delete encoder; return retval; @@ -668,6 +685,8 @@ int decompress( const unsigned long long unsigned long long partial_file_pos = 0; Range_decoder rdec( infd ); int retval = 0; + long long time_start = clock_ns(); + long long time_end; for( bool first_member = true; ; first_member = false ) { @@ -724,7 +743,14 @@ int decompress( const unsigned long long retval = 2; break; } if( verbosity >= 2 ) - { std::fputs( testing ? "ok\n" : "done\n", stderr ); pp.reset(); } + { + time_end = clock_ns(); + std::fprintf( stderr, "; %0.2f[s]: %0.2f[MiB/s]. %s", + (double)( time_end - time_start ) / 1e+9, + (decoder.data_position() / ((double)( time_end - time_start ) / 1e+9 )) / (1024*1024), + testing ? "ok\n" : "done\n"); + pp.reset(); + } } if( verbosity == 1 && retval == 0 ) std::fputs( testing ? "ok\n" : "done\n", stderr );