From patchwork Wed May 24 15:44:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 766517 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wXxXj4TcTz9s9Y for ; Thu, 25 May 2017 01:44:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="bbryPreL"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; q=dns; s=default; b=D7U5rDtBQ/JfwjEN z0WvkIXaTKNGzI51xjfn2zi7WqAr4InS4EV1xLkTCnWx0mNTpgu5vpZ9dQJxe09W X2yisDP7UhFdTnuoDUmXXjqS/EEfhVo0QmIYfDhIKxjde7CMxOza3jI6yWu5/eRt rPS/VgxFYFQKRxvFhhLIStwaIxg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; s=default; bh=RMZ4QeOM8X7FkzH1ibvlrw BNIJ8=; b=bbryPreLXBtCOsiAHWc5ytlHi+b0an/sA55MEx1jRUNAOfOLH5fH6O JDYd3/PCjnHu0mEw20SQ9uqnnDuRxmyxigMXEBltwayhJtIu4sAzqatTympzUI+F /RBqVpLb7Pz5bU97VvaYfK6bPfLdqqE1WcME/vaPuabZXErKeJIuw= Received: (qmail 113784 invoked by alias); 24 May 2017 15:44:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 113747 invoked by uid 89); 24 May 2017 15:44:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga11.intel.com X-ExtLoop1: 1 Date: Wed, 24 May 2017 08:44:22 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] benchtests: Add more tests for memrchr Message-ID: <20170524154422.GA14778@lucon.org> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.0 (2017-02-23) bench-memchr.c is shared with bench-memrchr.c. This patch adds some tests for positions close to the beginning for memrchr, which are equivalent to positions close to the end for memchr. Any comments? H.J. --- * benchtests/bench-memchr.c (do_test): Print out both length and position. (test_main): Also test the position close to the beginning for memrchr. --- benchtests/bench-memchr.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c index 16099ac..c95cc70 100644 --- a/benchtests/bench-memchr.c +++ b/benchtests/bench-memchr.c @@ -117,7 +117,8 @@ do_test (size_t align, size_t pos, size_t len, int seek_char) buf[align + len] = seek_char; } - printf ("Length %4zd, alignment %2zd:", pos, align); + printf ("Length %4zd, position %4zd, alignment %2zd:", + len, pos, align); FOR_EACH_IMPL (impl, 0) do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result); @@ -143,11 +144,27 @@ test_main (void) do_test (i, 64, 256, 23); do_test (0, 16 << i, 2048, 0); do_test (i, 64, 256, 0); +#ifdef USE_AS_MEMRCHR + /* Also test the position close to the beginning for memrchr. */ + do_test (0, i, 256, 23); + do_test (0, i, 256, 0); + do_test (i, i, 256, 23); + do_test (i, i, 256, 0); +#endif } for (i = 1; i < 32; ++i) { do_test (0, i, i + 1, 23); do_test (0, i, i + 1, 0); + do_test (i, i, i + 1, 23); + do_test (i, i, i + 1, 0); +#ifdef USE_AS_MEMRCHR + /* Also test the position close to the beginning for memrchr. */ + do_test (0, 1, i + 1, 23); + do_test (0, 2, i + 1, 0); + do_test (i, i, i + 1, 23); + do_test (i, i, i + 1, 0); +#endif } return ret;