mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-27 23:54:20 +02:00
update xfr rates on interval, not once per chunk
This commit is contained in:
parent
f0fc84d80c
commit
04bd831a9c
@ -158,6 +158,7 @@ export class FileUpload {
|
|||||||
}
|
}
|
||||||
this.done();
|
this.done();
|
||||||
}
|
}
|
||||||
|
this.update_rates_interval = setInterval(this.display_xfr_rate.bind(this), 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,6 +194,7 @@ export class FileUpload {
|
|||||||
done() {
|
done() {
|
||||||
this.proc.input(); // close stdin
|
this.proc.input(); // close stdin
|
||||||
this.remove_html_element();
|
this.remove_html_element();
|
||||||
|
clearInterval(this.update_rates_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_xfr_rate() {
|
update_xfr_rate() {
|
||||||
@ -200,12 +202,19 @@ export class FileUpload {
|
|||||||
var elapsed = (now - this.timestamp) / 1000;
|
var elapsed = (now - this.timestamp) / 1000;
|
||||||
this.timestamp = now;
|
this.timestamp = now;
|
||||||
var rate = this.chunk_size / elapsed;
|
var rate = this.chunk_size / elapsed;
|
||||||
this.rate.innerText = cockpit.format_bytes_per_sec(rate);
|
this.rate_avg = (this.rate_avg)
|
||||||
|
? (0.125 * rate + (0.875 * this.rate_avg))
|
||||||
|
: rate;
|
||||||
// keep exponential moving average of chunk time for eta
|
// keep exponential moving average of chunk time for eta
|
||||||
this.chunk_time = (this.chunk_time)
|
this.chunk_time = (this.chunk_time)
|
||||||
? (0.125 * elapsed + (0.875 * this.chunk_time))
|
? (0.125 * elapsed + (0.875 * this.chunk_time))
|
||||||
: elapsed;
|
: elapsed;
|
||||||
var eta = (this.num_chunks - this.chunk_index) * this.chunk_time;
|
var eta = (this.num_chunks - this.chunk_index) * this.chunk_time;
|
||||||
this.eta.innerText = format_time_remaining(eta);
|
this.eta_avg = eta;
|
||||||
|
}
|
||||||
|
|
||||||
|
display_xfr_rate() {
|
||||||
|
this.rate.innerText = cockpit.format_bytes_per_sec(this.rate_avg);
|
||||||
|
this.eta.innerText = format_time_remaining(this.eta_avg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user