Fix zpaq compression now updating the console too much because it's now so much faster it uses up a lot of CPU time just ouputting to the screen.

Do this by updating only every 10%, and print separate updates for each thread.
This commit is contained in:
Con Kolivas 2010-11-13 08:33:30 +11:00
parent 02de002c58
commit e9957e1115
3 changed files with 19 additions and 12 deletions

View file

@ -1694,7 +1694,8 @@ void Encoder::compress(int c) {
//////////////////////////// Compress ////////////////////////////
// Compress to 1 segment in 1 block
static void compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, int progress) {
static void compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len,
int progress, long thread) {
// Compiled initialization lists generated by "zpaq vtrmid.cfg"
static U8 header[71]={ // COMP 34 bytes from mid.cfg
@ -1708,7 +1709,7 @@ static void compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, i
long long int len = 0;
static int last_pct = 0, chunk = 0;
int pct = 0;
int i, pct = 0;
// Initialize
ZPAQL z; // model
z.load(34, 37, header); // initialize model
@ -1737,8 +1738,12 @@ static void compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, i
if (progress) {
len++;
pct = (len * 100 / buf_len);
if (pct != last_pct) {
fprintf(msgout, "\r\t\t\tZPAQ Chunk %i of 2 compress: %i%% \r", (chunk + 1), pct);
if (pct != last_pct && !(pct % 10)) {
fprintf(msgout, "\r\t\t\t\tZPAQ\t");
for (i = 0; i < thread; i++)
fprintf(msgout, "\t\t");
fprintf(msgout, "%d: %i/2: %i%%\r",
thread, (chunk + 1), pct);
fflush(msgout);
last_pct = pct;
}
@ -1747,8 +1752,8 @@ static void compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, i
sha1.put(c);
}
if (progress) {
fprintf(msgout, "\t \r");
fflush(msgout);
//fprintf(msgout, "\t \r");
//fflush(msgout);
}
enc.compress(-1); // end of segment
@ -1765,7 +1770,8 @@ static void compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, i
chunk ^= 1;
}
extern "C" void zpipe_compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, int progress)
extern "C" void zpipe_compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len,
int progress, long thread)
{
compress(in, out, msgout, buf_len, progress);
compress(in, out, msgout, buf_len, progress, thread);
}