From patchwork Mon Dec 25 10:21:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 1879983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=3AeSImQY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=B7j9Dmv+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SymbJ3flkz23dL for ; Mon, 25 Dec 2023 03:25:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4U9Wd8OaAbSIxl46YAiXnFs2DqAZmt1lnlcr+wq89Ss=; b=3AeSImQYaB0ZTl lZp9hxwDR/XSb4QTB2lXa0bBwit/xICOo4nbwLaBzugck/uHcQpdruGpRSiuShKy4KQ5phGntnyNn LPY8wWjmzd8IJ3O683LIErSNNlhlf02O+f8NfBQ8rbHVygmWqpIkbYsTLdosNM9RQ1EUmzim360IK e4ZVOWltBfyga3SNk6zGVdljyMn+e/RwUFBxE7cxiF/uP863HChhqLbCH7d9fryyl63fFW0e/I0K9 vsnRXr1csZ4VDcZhNCAMShhBgwtlCddV62oysjiMr6dx9C+15fdlieEpwIHMutsTdxDtOlhzWF6z1 XZwuJf1WJCEbpVIGq/8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rHRH6-009c9s-0d; Sun, 24 Dec 2023 16:24:24 +0000 Received: from mgamail.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rHRH3-009c18-2a for hostap@lists.infradead.org; Sun, 24 Dec 2023 16:24:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703435061; x=1734971061; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2CE96+4EhHTugKWpvt4Oof7aGgzsKWEyTQbrFznF54U=; b=B7j9Dmv+b2oe6kbbB3VxNwG5j0tIaR5uLC6Lo1bgYpNFIl/ejQeo0iY1 wfXI3qJH25JAcL3OWHFjyHXopW9UmYUmVS4dE31yhZv2BvBNKeo5DOsgr urO2lQc+OGJCvALjdYMIbadfNhL/H6QHfnwly9nTvCATo23ymp8j8P3Ln l7tQ7/RWpptrIuqhEHxpulFrxstu89NB43dt9uJWkmqYuf0uf1NND9rfO VfUC1ujDSrlD7aWXRKWsrRKwOzjeekLEhyGCL14qONNYwtnrel0YSQ+UB 9UXeBwZkHHTDmaY0tMlOcn/LIs9TIuKyuDqhYQl6aFmdcTK7KnK+gyJe7 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="482421001" X-IronPort-AV: E=Sophos;i="6.04,301,1695711600"; d="scan'208";a="482421001" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Dec 2023 08:24:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="777554334" X-IronPort-AV: E=Sophos;i="6.04,301,1695711600"; d="scan'208";a="777554334" Received: from unknown (HELO WEIS0042.iil.intel.com) ([10.12.217.211]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Dec 2023 08:24:20 -0800 From: Andrei Otcheretianski To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH 09/12] tests: Optimize process memory reading using join Date: Mon, 25 Dec 2023 12:21:06 +0200 Message-ID: <20231225102109.2853783-10-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225102109.2853783-1-andrei.otcheretianski@intel.com> References: <20231225102109.2853783-1-andrei.otcheretianski@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231224_082421_853523_502D7E66 X-CRM114-Status: GOOD ( 10.49 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Benjamin Berg Appending to a bytes() object is rather inefficient. As such, avoid doing so by first creating a list and then join'ing all buffers together at the end only. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [192.55.52.43 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.5 DATE_IN_FUTURE_12_24 Date: is 12 to 24 hours after Received: date -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Benjamin Berg Appending to a bytes() object is rather inefficient. As such, avoid doing so by first creating a list and then join'ing all buffers together at the end only. Signed-off-by: Benjamin Berg --- tests/hwsim/test_ap_psk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index ab76372578..d175259b53 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -2625,7 +2625,7 @@ def find_wpas_process(dev): raise Exception("Could not find wpa_supplicant process") def read_process_memory(pid, key=None): - buf = bytes() + buf = [] logger.info("Reading process memory (pid=%d)" % pid) with open('/proc/%d/maps' % pid, 'r') as maps, \ open('/proc/%d/mem' % pid, 'rb') as mem: @@ -2651,11 +2651,11 @@ def read_process_memory(pid, key=None): except OSError as e: logger.info("Could not read mem: start=%d end=%d: %s" % (start, end, str(e))) continue - buf += data + buf.append(data) if key and key in data: logger.info("Key found in " + l) logger.info("Total process memory read: %d bytes" % len(buf)) - return buf + return b''.join(buf) def verify_not_present(buf, key, fname, keyname): pos = buf.find(key)