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 03A7565A7D for ; Fri, 24 Jul 2020 07:52:41 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E5DF92E935 for ; Fri, 24 Jul 2020 07:52:40 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 180A62E92B for ; Fri, 24 Jul 2020 07:52:40 +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 CC25643288 for ; Fri, 24 Jul 2020 07:52:39 +0200 (CEST) Date: Fri, 24 Jul 2020 07:52:29 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20200723161637.6280-1-s.ivanov@proxmox.com> <20200723161637.6280-3-s.ivanov@proxmox.com> In-Reply-To: <20200723161637.6280-3-s.ivanov@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1595569359.wildxf6ij4.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.052 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 05:52:41 -0000 On July 23, 2020 6:16 pm, Stoiko Ivanov wrote: > in case the backup duration gets rounded to 0 seconds is this the only place where we calculate speed/throughput like this? if=20 not, would it make sense to have a helper that does it in a uniform=20 fashion? >=20 > Signed-off-by: Stoiko Ivanov > --- > src/client/backup_writer.rs | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) >=20 > 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_n= ame.clone()) > }; > if archive_name !=3D CATALOG_NAME { > - let speed: HumanByte =3D (uploaded / (duration.as_secs() as = usize)).into(); > - let uploaded: HumanByte =3D uploaded.into(); > - println!("{}: had to upload {} from {} in {}s, avgerage spee= d {}/s).", archive, uploaded, vsize_h, duration.as_secs(), speed); > + let hb_uploaded: HumanByte =3D uploaded.into(); > + match duration.as_secs() { > + 0 =3D> println!("{}: had to upload {} from {} in {}s", a= rchive, hb_uploaded, vsize_h, duration.as_secs()), s/from/of or s/from/out of also in this case, it would make sense to print 'in <1s' instead of 0s? or do we want to calculate speed based on the actual duration in that case?= =20 or in any case? if we switch to as_millis() it's already rather unlikely=20 to return 0 (although it would still need to be handled for very very=20 fast systems or broken time keeping) > + dur =3D> { > + let speed: HumanByte =3D (uploaded / (dur as usize))= .into(); > + println!("{}: had to upload {} from {} in {}s, (aver= age speed {}/s).", archive, hb_uploaded, vsize_h, duration.as_secs(), speed= ); 'from' is wrong here as well > + } > + } > } else { > println!("Uploaded backup catalog ({})", vsize_h); > } > --=20 > 2.20.1 >=20 >=20 >=20 > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel >=20 >=20 >=20 =