public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	 Thomas Lamprecht <t.lamprecht@proxmox.com>
Subject: Re: [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate
Date: Fri, 24 Jul 2020 14:01:40 +0200 (CEST)	[thread overview]
Message-ID: <808935848.14.1595592100554@webmail.proxmox.com> (raw)
In-Reply-To: <20200724081601.30073-1-t.lamprecht@proxmox.com>

Why don't you use a single duration.as_secs_f64() and compute speed using floting point?


> On 07/24/2020 10:16 AM Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
> 
>  
> using micros vs. as_secs_f64 allows to have it calculated as usize
> bytes, easier to handle - this was also used when it still lived in
> upload_chunk_info_stream
> 
> Co-authored-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
> ---
>  src/client/backup_writer.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
> index 7e5adb3..2344045 100644
> --- a/src/client/backup_writer.rs
> +++ b/src/client/backup_writer.rs
> @@ -264,7 +264,7 @@ 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 speed: HumanByte = ((uploaded * 1_000_000) / (duration.as_micros() 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);
>          } else {
> -- 
> 2.27.0
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




  parent reply	other threads:[~2020-07-24 12:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24  8:16 Thomas Lamprecht
2020-07-24  8:16 ` [pbs-devel] applied: [PATCH backup 2/2] client: log archive upload duration more accurate, fix grammar Thomas Lamprecht
2020-07-24 12:01 ` Dietmar Maurer [this message]
2020-07-24 12:37   ` [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate Thomas Lamprecht

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=808935848.14.1595592100554@webmail.proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=t.lamprecht@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal