From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D2C0665ABB for ; Fri, 24 Jul 2020 09:16:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C26462F206 for ; Fri, 24 Jul 2020 09:16:03 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id EBA8A2F1F9 for ; Fri, 24 Jul 2020 09:16:02 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B3305432DC for ; Fri, 24 Jul 2020 09:16:02 +0200 (CEST) Date: Fri, 24 Jul 2020 09:15:33 +0200 (CEST) From: Dietmar Maurer To: Proxmox Backup Server development discussion , Stoiko Ivanov Message-ID: <1013805395.481.1595574934177@webmail.proxmox.com> In-Reply-To: <20200723161637.6280-3-s.ivanov@proxmox.com> References: <20200723161637.6280-1-s.ivanov@proxmox.com> <20200723161637.6280-3-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.3-Rev17 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.015 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Subject: Re: [pbs-devel] [PATCH proxmox-backup 2/2] fix division by zero X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jul 2020 07:16:33 -0000 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 wrote: > > > in case the backup duration gets rounded to 0 seconds > > Signed-off-by: Stoiko Ivanov > --- > 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