From patchwork Tue Dec 12 17:41:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 81991 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 1574C3858C78 for ; Tue, 12 Dec 2023 17:42:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2078.outbound.protection.outlook.com [40.107.247.78]) by sourceware.org (Postfix) with ESMTPS id AE5273858C78 for ; Tue, 12 Dec 2023 17:42:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE5273858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AE5273858C78 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.247.78 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1702402923; cv=pass; b=bIx/HHFuOVG8qmIBqCEiemm2XpfFl9jgXJe35tpFhFKROwU4NSJYA1hQSYPHxdpJiIZLO0fs5b3hmWq6km4+krmFBhC49Nntnt21iVlg4SMNHollnsnwz+H8nFF/STn7ex2oHtZrYuVFvjdjxIEFTTztJkNW0dMb8aVBWL9B9u8= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1702402923; c=relaxed/simple; bh=JQPeOePRRQR9Ra7FPpf6gJqSrszWRQQvrj1aag74Jb0=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=s7aV/Q0ISn+D+E6UVgDnMqf3uFrmKT+3icVGPxEuKU59oWlVzHYBDSm+qd4II3E0RK8j1cHccq8Zw5gj6HS0IDHvxMJubSLf+pBVah9oyf5qWDpSG+O+18J7E0m4Wt4GXdOQRqzzrn1s3HJ+Oraqw/AbZNLbtfRPfu4u5KL6ieA= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=kbs27LFoCQN5DTZVFOPRZ9n7d/pIeqgDudMPh3XNkowdibCqQ5zUBRVIHHaR98k+dBFgQERpIVBIorwkxQV+3qNE7ecl1FHh7Wwp1vwHh7u/GhfpJ9KtvQ9i2KyRb2m659MZIN9JQP8LrD+LorZTc/yghCLQUefEfuYANtnCXQoJPiej/nfLc/8IceFEWx38VwWCFJ29/Qx9aJrgYulgtKmWG9/2wPi2QU1g0SyG0q8M4MSaQmMgmOBNYjEdjYUWYygifEQ8xtAP87aWOfE7ogNMe9oh/hKpr7WrmwlG6ERVrJ6nZMRG7lBO0TJkzHR8g/P//coI7EIE1AdqEZmbpg== ARC-Message-Signature: i=2; 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=WnYZ0FKTb0i6pe+dAr6KNOKkymn/zU5htXxVqmh/0vI=; b=N8MKebin5GJPNfq6v0Bg6LoNM//viNBecfm8yrR1TaX8KnrCCL81x+WvRRT1Cu5r0ux1088jWH4sEcTG+ZviwVRoHaXKXe1v61bGogFFdylywLA5xuqfaPvrzbJWEj4MsWIfkKMDLETTj0F+H7rIHLVGHFzVWpjaV94Rtnuqje6sfWPlumWi5HzB63iBtdYH2EkkrX6wYYFp4yrfrTMMNie5mY6givSpg0ZrEzGFDaK5K3UzH+W58HyLiJOnnByBZSKKhz3vc4GDOkhgZ+6o7ZFLMlzmRCVeyZVLSWCP9zj9+fMMdLS7vsEn+CNlzlwA9gUNgtvEOXqTag9KRn3qrw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WnYZ0FKTb0i6pe+dAr6KNOKkymn/zU5htXxVqmh/0vI=; b=im++7/GAjJX1FGcTTMkgEfibfuKKJO9Le7R0G+fgeRyXvHNgpy47qCt1d+DRandBU1ZhfcCoTYI87GCSGPoQouDs95gragZTyrBfaws4CTVqquT5Dwshncqinndye8kjrjKYBklnH/ENlqyKTNiDeqX9WDjFKag4vqvRWNrp9v0= Received: from AS9PR06CA0604.eurprd06.prod.outlook.com (2603:10a6:20b:46e::6) by AS8PR08MB8274.eurprd08.prod.outlook.com (2603:10a6:20b:536::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Tue, 12 Dec 2023 17:41:57 +0000 Received: from AM4PEPF00025F9B.EURPRD83.prod.outlook.com (2603:10a6:20b:46e:cafe::a0) by AS9PR06CA0604.outlook.office365.com (2603:10a6:20b:46e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33 via Frontend Transport; Tue, 12 Dec 2023 17:41:57 +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 AM4PEPF00025F9B.mail.protection.outlook.com (10.167.16.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.2 via Frontend Transport; Tue, 12 Dec 2023 17:41:57 +0000 Received: ("Tessian outbound 7c4ecdadb9e7:v228"); Tue, 12 Dec 2023 17:41:57 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 80ca9cbbb4a1655e X-CR-MTA-TID: 64aa7808 Received: from 4c4faf7a2150.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 29AF1E2F-41CB-463D-8C0D-9D4252CB9449.1; Tue, 12 Dec 2023 17:41:51 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4c4faf7a2150.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Dec 2023 17:41:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ecafM2q0cclQvkyLb0IebcpcsUhguFc3FC9jNFrUHjeXXHEeo/VsWdlkbnWFRFmevuzUcOSOEluV5rud2Fix5dj4dT9K7YB+ArCDg9oUKoFGBvkrtEHMd5Gv4+4iGZX86G08YONzJePd0LffZ3BGiXMh4bZ4PxwEHbdqQkZdNVr8RN4e7aBTk9Di8UXlt3WxgQBrlUSpqSb5C2EGvvmhcoY+gpRMJxWVFODMBdxtsPGB1HAAsWJkIlxqKfoPwOaTLOFdG4pkADN88gpJfoj6xYh6xgFX9rdO8/oHO0wBhhjJ+PxvjaXviaJOSnqr/EI1v+ODcPxa75wsqr5sjOKGJQ== 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=WnYZ0FKTb0i6pe+dAr6KNOKkymn/zU5htXxVqmh/0vI=; b=IkAzEeJmV2gw8aBVJm4g/Z8TmwJg3sHxvrv7V8S8bRyBF+VqhE9ORSwt80D2JMx2C1Evp0cNvokADiYBEcSH/2MOMXyA2OA60nQTK/SzTb7jENw31FkGW/OLbMXAB1PUAruyDN69/gxKp7ZHfVtVvYHFyVMC6nZorKEvOTDeunPM2njRc/UuFvHyUfKwnYiyqGBCMWFZRmxFeEuuqlrf6pxtpMxh3LucZ2LZdvSOb70RA1+Lb7wNQRGr0bx4uk8feBzaismusoExIuCH2VdXUuPsnjYXVx1NoeLoxaPPW2HBtpptYQ9i6oQ6l1dThYGZjFWfWxpxeGWmBiBYlpaHyA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WnYZ0FKTb0i6pe+dAr6KNOKkymn/zU5htXxVqmh/0vI=; b=im++7/GAjJX1FGcTTMkgEfibfuKKJO9Le7R0G+fgeRyXvHNgpy47qCt1d+DRandBU1ZhfcCoTYI87GCSGPoQouDs95gragZTyrBfaws4CTVqquT5Dwshncqinndye8kjrjKYBklnH/ENlqyKTNiDeqX9WDjFKag4vqvRWNrp9v0= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by DBBPR08MB10463.eurprd08.prod.outlook.com (2603:10a6:10:532::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Tue, 12 Dec 2023 17:41:46 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::2ed5:dc23:2624:df0a]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::2ed5:dc23:2624:df0a%7]) with mapi id 15.20.7068.031; Tue, 12 Dec 2023 17:41:46 +0000 From: Wilco Dijkstra To: 'GNU C Library' Subject: [PATCH v2 1/2] Add random benchmark Thread-Topic: [PATCH v2 1/2] Add random benchmark Thread-Index: AQHaLSJQJB5xulKPW0CIceEnqvRhaQ== Date: Tue, 12 Dec 2023 17:41:45 +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_|DBBPR08MB10463:EE_|AM4PEPF00025F9B:EE_|AS8PR08MB8274:EE_ X-MS-Office365-Filtering-Correlation-Id: fe639b97-2bb0-4dad-a4a6-08dbfb39a376 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: mEbXeQwaqOXGbWryEqjNSQizhDpRabMPrE/mNTvEDt7tPnn4mVv7ldhwM0Hmi9ZePYEajoU0LkEARnEE50k9UuTDuJ/t+wtLR67yGycAyGR1FIEyYV1lJJS8JC5/4BWTIhadG7aRT7lyy7+7KRHL0EMGmnpdVnF6NUQioQBuIJ5vFocR3oEzQSg1TMR3GqB4k6w0V1+ypgWuEBl8+MikpdsFBcEmWj8V3GMjZ64EVXvl7TmbbsdRRjpTxoUa3M0M4QKfA2JmMjpVvlUoUBJUZKWTTcjxnDdzggaaVPDwTKwA+1jmbPQdqsNfpMXxbENfvYojo6Zz/SKdQSlgjXZ1HlNeP0IJMAUuwcHNTz/tO856xl8eYacHSwAUaQnPgkGIMRCszkyI/op319KRzc+5PvpjyN1mGfOrdti/jx3J81yg+Xd7D1Jv75g8/M/AV/7R4fYXs3Kj4/qMMdVEQZiHNV855sUjqal5vge3zKmXsMiGkGerN/SNAbwm1oRQsVuu2grG3G7eBLZVKjpKqg9FiAqL3BZfyU3VFxPTvWWSjwnGqZ3p1vTiJG9lRQHW/XyiJCiOwrtLEq1W3j+lbO6Ldv+DlXr/s0sPhy+JvYegm0UZGA38QG6kJ0gaHJE4L9lq 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:(13230031)(136003)(396003)(366004)(376002)(39860400002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(91956017)(66476007)(76116006)(66556008)(66446008)(316002)(66946007)(64756008)(7696005)(9686003)(41300700001)(26005)(71200400001)(38070700009)(38100700002)(86362001)(122000001)(6506007)(33656002)(83380400001)(478600001)(2906002)(52536014)(6916009)(5660300002)(55016003)(8676002)(8936002)(2004002); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB10463 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: AM4PEPF00025F9B.EURPRD83.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 19ea9de2-b7b2-4571-4f2f-08dbfb399c63 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: okUlo8OSB19pofwHvihkfdARcNKcSSExpUsnDmPuG3/ngtYPtfWNtyIMyYLRGrtgAdeNZ/eV7UXwrKdIxrCpVsklF44GTciS4hKa14JOggo5g7/TX4OTs7xdpOvY5wZRyFLlu8y4KVmWuDh0VVgjCKO67k+q0rh4EeAvsbFLatHrvEkq0aeLhqJ9G56sQk0rmCNO1s4pjYILKw3/UO9Ugg4/2B36nYRTpovQdmxQPj3hABWRsKh+1+5+7NPCrZQ3MRTMIZ5NJvqOeD5qNC3Ib4HLfTq06ZI8Ri73WIFBYIHhRqqnPOmqkLpMg28iHgtqBTxaEdSb8H5+/bjMYqXgqm137x0HL+XCvr5jVVMK4AIsgAu1J/ntEUYJCEHt/QUs7M85G2f2gbfoRACo7isk1kNWMOSfxJ0ptezrZdtLWQHTKQf821msp/3nPXgFT9aovrgNt0XHN9wnkavIZiqRN3gTx4Bxst+ju2BinqsQ3Pqc+npXG/j+6Om47FeEjv4fD/aF3Cw4Odvq9DSpAE8/KTxUD5iWAGjaq6qZT58KRpPf4Yen1omZ92WJJFzCSmszZ7JHReJUpC89rA/wPHdgNeff4+EVsS0QRp3DnAGc7KXqzhDAvzctT/hlUDHnGbwnTdtBL0AKwyDcMHzEi+4+hYrJJKMNYICGuAog1jZx2zDKB+LZVqs2Zq5bd40lM6Me4zeIVzvr162tgKxQ4/ktTF8/ypFh23YLW2RYYtrOnZmsloCi2vVOEXjNA2EGXGxt 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:(13230031)(4636009)(346002)(396003)(39860400002)(136003)(376002)(230922051799003)(186009)(64100799003)(82310400011)(451199024)(1800799012)(40470700004)(36840700001)(46966006)(40480700001)(55016003)(86362001)(33656002)(6506007)(41300700001)(7696005)(70586007)(70206006)(81166007)(356005)(82740400003)(478600001)(26005)(336012)(9686003)(40460700003)(83380400001)(2906002)(6916009)(316002)(36860700001)(52536014)(47076005)(8676002)(5660300002)(8936002)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 17:41:57.6757 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe639b97-2bb0-4dad-a4a6-08dbfb39a376 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: AM4PEPF00025F9B.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8274 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, 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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Add a simple benchmark to measure the overhead of internal libc locks in the random() implementation on both single- and multi-threaded cases. diff --git a/benchtests/Makefile b/benchtests/Makefile index e1346bbda125be9fc2b216f9e8be3f2ee7cb0c4d..1ec14078ab73d7c1c0fa1d4d870a075a66543a5c 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -246,6 +246,7 @@ hash-benchset := \ stdlib-benchset := \ arc4random \ + random-lock \ strtod \ # stdlib-benchset diff --git a/benchtests/bench-random-lock.c b/benchtests/bench-random-lock.c new file mode 100644 index 0000000000000000000000000000000000000000..29a02ae9ff3a81114e8dd7e1dddcb3309b92df6c --- /dev/null +++ b/benchtests/bench-random-lock.c @@ -0,0 +1,108 @@ +/* Benchmark internal libc locking functions used in random. + Copyright (C) 2022-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define TEST_MAIN +#define TEST_NAME "random-lock" + +#include +#include +#include +#include "bench-timing.h" +#include "json-lib.h" + +/* Modern cores run 20M iterations in about 1 second. */ +#define NUM_ITERS 50000000 + +json_ctx_t json_ctx; + + +/* Measure the overhead of __libc_lock_lock and __libc_lock_unlock by + calling random (). */ +static void +bench_random_lock (size_t iters) +{ + timing_t start, stop, total; + + srandom (0); + + /* Warmup to reduce variations due to frequency scaling. */ + for (int i = 0; i < iters / 4; i++) + (void) random (); + + TIMING_NOW (start); + + for (int i = 0; i < iters; i++) + (void) random (); + + TIMING_NOW (stop); + + TIMING_DIFF (total, start, stop); + + json_element_double (&json_ctx, (double) total / (double) iters); +} + +static void * +thread_start (void *p) +{ + return p; +} + +int +do_bench (void) +{ + 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, "random"); + json_attr_string (&json_ctx, "bench-variant", "single-threaded"); + json_array_begin (&json_ctx, "results"); + + /* Run benchmark single threaded. */ + bench_random_lock (NUM_ITERS); + + json_array_end (&json_ctx); + json_attr_object_end (&json_ctx); + + json_attr_object_begin (&json_ctx, "random"); + json_attr_string (&json_ctx, "bench-variant", "multi-threaded"); + json_array_begin (&json_ctx, "results"); + + /* Start a short thread to force SINGLE_THREAD_P == false. This relies on + the runtime disabling single-threaded optimizations when multiple + threads are used, even after they finish. */ + + pthread_t t; + pthread_create (&t, NULL, thread_start, NULL); + pthread_join (t, NULL); + + /* Repeat benchmark with single-threaded optimizations disabled. */ + bench_random_lock (NUM_ITERS); + + json_array_end (&json_ctx); + json_attr_object_end (&json_ctx); + json_attr_object_end (&json_ctx); + json_document_end (&json_ctx); + return 0; +} + +#define TEST_FUNCTION do_bench () + +#include "../test-skeleton.c"