From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Stoiko Ivanov <s.ivanov@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup 2/2] fix division by zero
Date: Fri, 24 Jul 2020 09:15:33 +0200 (CEST) [thread overview]
Message-ID: <1013805395.481.1595574934177@webmail.proxmox.com> (raw)
In-Reply-To: <20200723161637.6280-3-s.ivanov@proxmox.com>
Why do we use duration.as_secs() here?
We can do better by using floating point values using duration.as_secs_f64() to calculate
the speed more exactly.
> On 07/23/2020 6:16 PM Stoiko Ivanov <s.ivanov@proxmox.com> wrote:
>
>
> in case the backup duration gets rounded to 0 seconds
>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> src/client/backup_writer.rs | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
> index 7e5adb3c..c2db2e76 100644
> --- a/src/client/backup_writer.rs
> +++ b/src/client/backup_writer.rs
> @@ -264,9 +264,14 @@ impl BackupWriter {
> crate::tools::format::strip_server_file_expenstion(archive_name.clone())
> };
> if archive_name != CATALOG_NAME {
> - let speed: HumanByte = (uploaded / (duration.as_secs() as usize)).into();
> - let uploaded: HumanByte = uploaded.into();
> - println!("{}: had to upload {} from {} in {}s, avgerage speed {}/s).", archive, uploaded, vsize_h, duration.as_secs(), speed);
> + let hb_uploaded: HumanByte = uploaded.into();
> + match duration.as_secs() {
> + 0 => println!("{}: had to upload {} from {} in {}s", archive, hb_uploaded, vsize_h, duration.as_secs()),
> + dur => {
> + let speed: HumanByte = (uploaded / (dur as usize)).into();
> + println!("{}: had to upload {} from {} in {}s, (average speed {}/s).", archive, hb_uploaded, vsize_h, duration.as_secs(), speed);
> + }
> + }
> } else {
> println!("Uploaded backup catalog ({})", vsize_h);
> }
> --
> 2.20.1
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
prev parent reply other threads:[~2020-07-24 7:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-23 16:16 [pbs-devel] [PATCH proxmox-backup 0/2] fix 2885 and a " Stoiko Ivanov
2020-07-23 16:16 ` [pbs-devel] [PATCH proxmox-backup 1/2] fix 2885: bail on duplicate backup target Stoiko Ivanov
2020-07-24 9:12 ` [pbs-devel] applied: " Thomas Lamprecht
2020-07-23 16:16 ` [pbs-devel] [PATCH proxmox-backup 2/2] fix division by zero Stoiko Ivanov
2020-07-24 5:52 ` Fabian Grünbichler
2020-07-24 7:15 ` Dietmar Maurer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1013805395.481.1595574934177@webmail.proxmox.com \
--to=dietmar@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=s.ivanov@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.