From patchwork Wed Mar 8 10:44:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1754027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=vX+W4vLO; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PWprW3jPtz1yWs for ; Wed, 8 Mar 2023 21:46:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7ED713857400 for ; Wed, 8 Mar 2023 10:46:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7ED713857400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678272361; bh=Z2gFnsm5oG16D1X33Oo4HMQsVciHwLzyoHmpWTPSQCY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vX+W4vLOEiRFL0UWdxRrP5vKHwmBNHS6MSj21pE8PEhvGXEwl9MACYDibNZ2kXl0m p57gu70TuoDPM2+uuCCn6x0U7LffYVpcL9GN7gm08O2+b5cOhT0aNPaTn0sp1+NCnS U0pgX5K7bQCQpTDd8Y3J3S1DQid19yz0RoF6jUno= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2042.outbound.protection.outlook.com [40.107.104.42]) by sourceware.org (Postfix) with ESMTPS id 08A573851ABD for ; Wed, 8 Mar 2023 10:44:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08A573851ABD Received: from DB8PR06CA0008.eurprd06.prod.outlook.com (2603:10a6:10:100::21) by GVXPR08MB7704.eurprd08.prod.outlook.com (2603:10a6:150:6a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Wed, 8 Mar 2023 10:44:50 +0000 Received: from DBAEUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:100:cafe::ba) by DB8PR06CA0008.outlook.office365.com (2603:10a6:10:100::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Wed, 8 Mar 2023 10:44:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT046.mail.protection.outlook.com (100.127.142.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29 via Frontend Transport; Wed, 8 Mar 2023 10:44:50 +0000 Received: ("Tessian outbound 0df938784972:v135"); Wed, 08 Mar 2023 10:44:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8613965a10e0df02 X-CR-MTA-TID: 64aa7808 Received: from f76f6fc23534.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 24BE4498-4411-4613-921E-CFE06C6F8717.1; Wed, 08 Mar 2023 10:44:44 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f76f6fc23534.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Mar 2023 10:44:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h9l2dRvsqACF+or0dqQj7891HfHlSqG4TnDPZDSlGGDeS7f2pRbKVTXUk8TnjC0vKz3SEDZFdabOCrHpn1lzG0ZN3XFMGKonoM5h70xicWPxiJyDpGXQW3zz3JLkeR65dCg5wWOPHyAWs/phv0gN3w4YDE1xE1+n4NpqF6C73WBgEa3n9S5WvZdw0LO/5zTbMB9cYUXeCbvR4+r2YBQkWWLSqpwBuSEKxG9hg49vCvuS30/hdJ/SX5IQS2qP+7L3GIQZ31eMKfYpvx+JQdSzJ8DrA2BWQuJn2lhTvvphPmcV4eXZUXKSol/fi8O5dTQsn+eN/PIofWd06L6Kr4PIBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z2gFnsm5oG16D1X33Oo4HMQsVciHwLzyoHmpWTPSQCY=; b=jJlmwkAo0Ct7Ui8xJDX0PxtZi5lGsx2Iq/AwFsqVioVEkugFtla0C+qyQQFOSdG6QB1/Rbzz/p+PDNv1vKULJt3T5jt8HE1eFFgxR0si6Qmd7NwFFSy5jar3lcQRKOO+6JXwDrYgwU5X7nnrVHjdTuiY6NEp9Lgzu6wZ2f8BaRh/Iv+hjxMNxivJ6F1pFKEMwW7e583mlodiYuaV6VhBxTDv5gH4aRf9yueMvyBQEjY6fdzbWHu95enSxq7ogE+5JmBtLqTO0z1bF1ejO80QIDBP4DRVObitiQwi98XGoG+VpOrqaSAldfqbYPWl22St6fR4Kj3sD3vmGxpG/qT/Iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by DB9PR08MB8459.eurprd08.prod.outlook.com (2603:10a6:10:3d5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 10:44:42 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::dc17:8fa2:cce5:3573]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::dc17:8fa2:cce5:3573%7]) with mapi id 15.20.6156.025; Wed, 8 Mar 2023 10:44:42 +0000 To: 'GNU C Library' Subject: [PATCH] Benchtests: Remove simple_mem(r)chr Thread-Topic: [PATCH] Benchtests: Remove simple_mem(r)chr Thread-Index: AQHZUarIAlQSKX7zX0yQQ11cLXQUvA== Date: Wed, 8 Mar 2023 10:44:42 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAWPR08MB8982:EE_|DB9PR08MB8459:EE_|DBAEUR03FT046:EE_|GVXPR08MB7704:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a430094-4dc3-41cc-9f2f-08db1fc224fb x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: /djruNZRRAoHC5oE0zuWmIJWyL9amimVH6zq1OJM7wclgk2J2sLwY6uno0h/76EeylnfWTLuZPDdfcJ8rnPFMNSnOagqpSuADiWN6Hc8TlkyEbjKh2C3KvrA5lOfpb2bLos8XpywuzY4kl7D/5GnbJMkSXNt0/3CjQfp+v+IEJG5Mbep6E+YOFE3hietY8KQpW8Cjokkm4hgz7QolGgwNnVIE8xS0zCt2li1soB8Qou16JhGLzuI1QNwm4lqS+bWBq37e5LiDXEybmUSf7K5IiOhPv8dAvfdv8A8lVjHC4e+WeN4r/pIZ54l+s/CfNoa6yjEr3MOEqNgv0nJ9SrhpNVE7LyOsJgeSfXkyk36QK/zNEXoeO+3VX/Kfodt8dg2sZavFzyxLbEBlYQFcSAS9Uv66vpWdw5bEh8Vmwjo9xE85SXIkdk4El1sDXZYD3tjCuNb4Jk3GFyL6pwagv77vS1qVkerUwL/L7MHLQoUzNmPhuHiDAn2qmQjEQxWD8AChrwcLiuH/f+TvdQqt4cK8LFSghcMnckm/b3y5bzrTXrZbXWORj7XzevXT/BvpNQ10ajb2Gy5FJyIdNMKbYPE/KvBgbLUK9N/oYOp6WAf+t+n/yWoXnkGPmGOp4juKcTVg+QDfYd4AO5/7v4x0oJQTieKQKPfwtOd3nwkTCZoaADRT52eDX/lSF/ku5WpYiwe X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8982.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(376002)(346002)(39860400002)(396003)(136003)(366004)(451199018)(33656002)(478600001)(71200400001)(316002)(7696005)(52536014)(5660300002)(8936002)(76116006)(2906002)(66556008)(91956017)(66446008)(66946007)(66476007)(64756008)(8676002)(6916009)(41300700001)(186003)(122000001)(38070700005)(55016003)(86362001)(9686003)(38100700002)(26005)(6506007); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB8459 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cc73acf3-20f8-4948-126c-08db1fc21fdb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9hcOTHtHozCypzoJXFGgwkpmE2f1U+EJ6FXOyzejVwEjKo7ItzzjdR0mvKc6rOClpL5nI54Lc8akVCvqVxjKsI/Znb9afgcFubx7usYUOonRiC4VDY9BAPXWSQpJhpqWueBnKrFgOW3ipHpYA2pHPkKAYksN9EuZdiO4TtB95M/jSXLUA+0qvnHsRTmEiZnXAUASZDa+lyn+8FPksAHbSXWKI36a5zpyj6rnwuU2ovYbGaJcgMpuhf5s7pqS7lgOfja5xz7O5k4Gfm8kvEVG1++BetapnJM7qjLZlcLt3Sst5mGPUR+NJ1BbFmwHjwnGNmC92VcZGZQmqSRdAux91ijJnFfcFDxQA9A4RFBhXJDy+fiESSrZILAdPZJ9jy07KTq6EHysUgPAX8abeHR9W/TKX4SGcfF2itb74q4TzpnhCKJbu2w2NgMfI/crV5sAz03tY4ZN67CUSF4Gj6K+5doQre8Y5Sog4a6HWvHBYz9Tm7EhdnwI0fpoRLl/34j4JmRBDz73QEZ2pAGzCAV67LEkyiE2nXCPs8/jZSH5vyFz2/P6eZMgw3jQhzUCYQt925H0zfCgeoq5zRaD0VlNnEHEQKsDdq8ZSqUJk/xCsg0gz39sNGq+C1/+HugujMD9pewgfpp0dulTCKm8kAqjB4S/GOy+HRohVLXb6b1r/1EZLU5vqNicvcUknWU+KoJN X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(396003)(39860400002)(376002)(346002)(451199018)(36840700001)(46966006)(40470700004)(36860700001)(33656002)(86362001)(356005)(81166007)(70206006)(5660300002)(2906002)(70586007)(41300700001)(6916009)(8936002)(82740400003)(8676002)(52536014)(82310400005)(40480700001)(40460700003)(186003)(336012)(9686003)(47076005)(26005)(316002)(55016003)(6506007)(7696005)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 10:44:50.7487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a430094-4dc3-41cc-9f2f-08db1fc224fb X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB7704 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Instead of benchmarking a slow byte oriented loops, include the optimized generic memchr/memrchr implementation. Adjust iteration count to reduce benchmark time. Reviewed-by: Adhemerval Zanella diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c index b99995e293f30a0ddbc68722552764b804521eb4..90bd3879e32e81950c633cf7f2d4f3f6a92d2311 100644 --- a/benchtests/bench-memchr.c +++ b/benchtests/bench-memchr.c @@ -16,6 +16,8 @@ License along with the GNU C Library; if not, see . */ +#include "json-lib.h" + #ifndef WIDE # define SMALL_CHAR 127 #else @@ -31,35 +33,25 @@ # endif /* WIDE */ # include "bench-string.h" -# ifndef WIDE -# define SIMPLE_MEMCHR simple_memchr -# else -# define SIMPLE_MEMCHR simple_wmemchr -# endif /* WIDE */ +typedef void *(*proto_t) (const void *, int, size_t); -typedef CHAR *(*proto_t) (const CHAR *, int, size_t); -CHAR *SIMPLE_MEMCHR (const CHAR *, int, size_t); +void * +generic_memchr (const void *, int, size_t); -IMPL (SIMPLE_MEMCHR, 0) IMPL (MEMCHR, 1) -CHAR * -SIMPLE_MEMCHR (const CHAR *s, int c, size_t n) -{ - while (n--) - if (*s++ == (CHAR) c) - return (CHAR *) s - 1; - return NULL; -} +# ifndef WIDE +IMPL (generic_memchr, 0) +# endif + #endif /* !USE_AS_MEMRCHR */ -#include "json-lib.h" static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, int c, size_t n) { - size_t i, iters = INNER_LOOP_ITERS_LARGE; + size_t i, iters = INNER_LOOP_ITERS; timing_t start, stop, cur; TIMING_NOW (start); @@ -250,3 +242,15 @@ test_main (void) } #include + +#ifndef WIDE +# ifndef USE_AS_MEMRCHR +# undef MEMCHR +# define MEMCHR generic_memchr +# include +# else +# undef MEMRCHR +# define MEMRCHR generic_memrchr +# include +# endif +#endif diff --git a/benchtests/bench-memrchr.c b/benchtests/bench-memrchr.c index 4f594ee7cdbe05c3ec4425b5d922ce2b9912b660..1f8c8845037db84ca0d4201ed991a09cdf19d57d 100644 --- a/benchtests/bench-memrchr.c +++ b/benchtests/bench-memrchr.c @@ -21,20 +21,12 @@ #include "bench-string.h" typedef char *(*proto_t) (const char *, int, size_t); -char *simple_memrchr (const char *, int, size_t); -IMPL (simple_memrchr, 0) -IMPL (memrchr, 1) +void * +generic_memrchr (const void *, int, size_t); -char * -simple_memrchr (const char *s, int c, size_t n) -{ - s = s + n; - while (n--) - if (*--s == (char) c) - return (char *) s; - return NULL; -} +IMPL (memrchr, 1) +IMPL (generic_memrchr, 0) #define USE_AS_MEMRCHR #include "bench-memchr.c"