From patchwork Wed May 12 14:27:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Castanho X-Patchwork-Id: 43393 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35F593835424; Wed, 12 May 2021 14:27:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35F593835424 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620829647; bh=j3Lc1uM+5InwczLZvCWurPkQ0Rp2ZDPo3WYNtPkvWAI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=F1kX+++3BIlV5IZY6E/Mv5LRAmzhgkdA+XAyHeFKr5OM1296gUsvtJ+8BIdNQ4rRf Dbo25Hq1XxyIMOEczjl5uWxIOVuvANlgkp4HD2T2D1VZqg/o3NWHwHnqmQrdxfZumu C497bjGduafi0b/LF4WJ9kwJxnFsoCm66E0ZrsVY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 8B3B9383583F for ; Wed, 12 May 2021 14:27:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8B3B9383583F Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14CE5EPV182697 for ; Wed, 12 May 2021 10:27:22 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 38gfagb146-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 May 2021 10:27:22 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14CEE53C004067 for ; Wed, 12 May 2021 14:27:20 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03wdc.us.ibm.com with ESMTP id 38dj995x7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 May 2021 14:27:20 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14CERJsb19202502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 14:27:19 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 471C0BE06F for ; Wed, 12 May 2021 14:27:19 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C67C4BE053 for ; Wed, 12 May 2021 14:27:18 +0000 (GMT) Received: from localhost (unknown [9.160.142.149]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP for ; Wed, 12 May 2021 14:27:18 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCH 1/2] benchtests: Use JSON for bench-rawmemchr output Date: Wed, 12 May 2021 11:27:16 -0300 Message-Id: <20210512142717.225429-1-msc@linux.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: xwAsnhj7-VoP0l-uzYLJgUjWxlVbXizg X-Proofpoint-ORIG-GUID: xwAsnhj7-VoP0l-uzYLJgUjWxlVbXizg X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-05-12_07:2021-05-12, 2021-05-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 adultscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120094 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Matheus Castanho via Libc-alpha From: Matheus Castanho Reply-To: Matheus Castanho Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Convert the output of benchtests/bench-rawmemchr to JSON like other string benchmarks. This makes the output more parseable and allows usage of compare_strings.py, for example. Reviewed-by: Lucas A. M. Magalhaes --- benchtests/bench-rawmemchr.c | 54 ++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/benchtests/bench-rawmemchr.c b/benchtests/bench-rawmemchr.c index 93b4a1ea38..80286b04b0 100644 --- a/benchtests/bench-rawmemchr.c +++ b/benchtests/bench-rawmemchr.c @@ -23,6 +23,8 @@ #define TEST_NAME "rawmemchr" #include "bench-string.h" +#include "json-lib.h" + typedef char *(*proto_t) (const char *, int); char * @@ -37,7 +39,7 @@ IMPL (rawmemchr, 1) IMPL (generic_rawmemchr, 0) static void -do_one_test (impl_t *impl, const char *s, int c, char *exp_res) +do_one_test (json_ctx_t *json_ctx, impl_t *impl, const char *s, int c, char *exp_res) { size_t i, iters = INNER_LOOP_ITERS_LARGE * 4; timing_t start, stop, cur; @@ -59,11 +61,11 @@ do_one_test (impl_t *impl, const char *s, int c, char *exp_res) TIMING_DIFF (cur, start, stop); - TIMING_PRINT_MEAN ((double) cur, (double) iters); + json_element_double (json_ctx, (double) cur / (double) iters); } static void -do_test (size_t align, size_t pos, size_t len, int seek_char) +do_test (json_ctx_t *json_ctx, size_t align, size_t pos, size_t len, int seek_char) { size_t i; char *result; @@ -86,39 +88,61 @@ do_test (size_t align, size_t pos, size_t len, int seek_char) buf1[align + len] = -seek_char; result = (char *) (buf1 + align + pos); - printf ("Length %4zd, alignment %2zd:", pos, align); + json_element_object_begin (json_ctx); + json_attr_uint (json_ctx, "length", pos); + json_attr_uint (json_ctx, "alignment", align); + json_attr_uint (json_ctx, "char", seek_char); + json_array_begin (json_ctx, "timings"); FOR_EACH_IMPL (impl, 0) - do_one_test (impl, (char *) (buf1 + align), seek_char, result); + do_one_test (json_ctx, impl, (char *) (buf1 + align), seek_char, result); - putchar ('\n'); + json_array_end (json_ctx); + json_element_object_end (json_ctx); } int test_main (void) { + json_ctx_t json_ctx; size_t i; test_init (); - printf ("%20s", ""); + json_init (&json_ctx, 0, stdout); + + json_document_begin (&json_ctx); + json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); + + json_attr_object_begin (&json_ctx, "functions"); + json_attr_object_begin (&json_ctx, TEST_NAME); + json_attr_string (&json_ctx, "bench-variant", ""); + + json_array_begin (&json_ctx, "ifuncs"); FOR_EACH_IMPL (impl, 0) - printf ("\t%s", impl->name); - putchar ('\n'); + json_element_string (&json_ctx, impl->name); + json_array_end (&json_ctx); + + json_array_begin (&json_ctx, "results"); for (i = 1; i < 7; ++i) { - do_test (0, 16 << i, 2048, 23); - do_test (i, 64, 256, 23); - do_test (0, 16 << i, 2048, 0); - do_test (i, 64, 256, 0); + do_test (&json_ctx, 0, 16 << i, 2048, 23); + do_test (&json_ctx, i, 64, 256, 23); + do_test (&json_ctx, 0, 16 << i, 2048, 0); + do_test (&json_ctx, i, 64, 256, 0); } for (i = 1; i < 32; ++i) { - do_test (0, i, i + 1, 23); - do_test (0, i, i + 1, 0); + do_test (&json_ctx, 0, i, i + 1, 23); + do_test (&json_ctx, 0, i, i + 1, 0); } + json_array_end (&json_ctx); + json_attr_object_end (&json_ctx); + json_attr_object_end (&json_ctx); + json_document_end (&json_ctx); + return ret; }