From patchwork Wed Dec 13 14:08:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 82060 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 C3DEC3857C72 for ; Wed, 13 Dec 2023 14:09:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2054.outbound.protection.outlook.com [40.107.241.54]) by sourceware.org (Postfix) with ESMTPS id 9B9693858C2F for ; Wed, 13 Dec 2023 14:08:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B9693858C2F 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 9B9693858C2F Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.241.54 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1702476544; cv=pass; b=mwqQD15Z7FiYhnGwaoAi+dzWJuAU3MRtDc8tXNIJ2IdwiXL9RhXQo3t/jc/FQITjrUJSADpUHgso6UUGUsaFD9EOsoanyIeEW/kKaCbusCFMavjD0/8H6BsxRrLLVNXJcMKFwmY2csZ4h4TfkWQXhItnTvjFy8uc1qFK8rUCiUg= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1702476544; c=relaxed/simple; bh=icpgXOYmCTgytcUVx7ePh3FLy7uSgM5uizRgCXv23QY=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=M5xVRsweBjFAPQnDpZcgJprwHmBzF0qXMEltYfpkjHGtFnCMNFMHRKRuhJl/F9O4ff7DzhX2rmnoCd8s4VG382uhWuiARJgbbJ4qwWkLN04TfYAiEm1OI0lRVUfQSzpAaFOBGN24TPOhChxA7FAlTqpNMYfxE782IShANTT2glY= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=F2oh4EAnL1phNFSZxxyZrsTfBQsYGOt4vqto+QERZ1IJSTB4Z2bfCQNtlVS5yiOKPCmfwrZDWYxrwhaG8YrGs400PFUmh4lurvz9i9fofAiS+KSqNm5gh8984VQgK8ZBNeVtqH2uH14QrXhGR76nc7GFupVLgYw/cHgqns+adi89fEc84KrYharHx05i25JcpEpkJuhtChZDYulsIRzrtIuZLufsbEfj/uqrHfnscODrHXXwPF7/fAD0JJgtob+WSdjYdxs2KScpDijQ1ecKkoA3NaUhFOhvMQutiV/wJb8pG9IDf7UOSJhQcyD/UWMXciTNedb4/sZgwdtyyHk6SQ== 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=icpgXOYmCTgytcUVx7ePh3FLy7uSgM5uizRgCXv23QY=; b=R8vT3+0PxW3OgdB619lhcHFlIYF4JFF7NPy3TPXY6imoKJKwwHwGdtc6AP1tq/8rgXxZTLmyzBJo+t9LLigh4P+ZamwTxIymN2xJROd6iw/wwfEhOvVnEd176YY5tRx1o3994vZqdDhvKDlylKeg3XbvvwoAyBITvF3Cg2lrulmM0jMttmSRARb4Tdd03sWx2U0QzYZd3Ea9g1Mn5XWeqPRQAw7O9dTf1G8AEPJbE6wSXdjXwzrim3viN80DlIXUkZoISJv7LQ4dpC4Bj5D/9Yx+2uZRDNLF+cv/c+irEDLeeomshwGjhlJqX6ap3buo2tWGp3toBOvsnCeg/qe0Kw== 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=icpgXOYmCTgytcUVx7ePh3FLy7uSgM5uizRgCXv23QY=; b=Uj710irO0aZkOXN0cFhtzK5705b0qXh0YySZW6INxCdHtEthbol+nNty6B8KvDpaBGjHj3HFRKJuiDBsU0uL05j5QqGDlXfhtUBU6mhfm2qu/oCW9f3P84fs1Gxlztf89ROst8eREfSZ+m2nxL3/nQn1i5+KuYi7qGgZwbk7slY= Received: from DU7PR01CA0047.eurprd01.prod.exchangelabs.com (2603:10a6:10:50e::24) by AS2PR08MB10226.eurprd08.prod.outlook.com (2603:10a6:20b:62f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26; Wed, 13 Dec 2023 14:08:50 +0000 Received: from DB5PEPF00014B99.eurprd02.prod.outlook.com (2603:10a6:10:50e:cafe::5b) by DU7PR01CA0047.outlook.office365.com (2603:10a6:10:50e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26 via Frontend Transport; Wed, 13 Dec 2023 14:08: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 DB5PEPF00014B99.mail.protection.outlook.com (10.167.8.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26 via Frontend Transport; Wed, 13 Dec 2023 14:08:49 +0000 Received: ("Tessian outbound 26ee1d40577c:v228"); Wed, 13 Dec 2023 14:08:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 742f66f3b2f391d5 X-CR-MTA-TID: 64aa7808 Received: from 507788ded535.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7C40D386-3923-41DE-B1E6-0C9DDF8AEFAB.1; Wed, 13 Dec 2023 14:08:43 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 507788ded535.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 13 Dec 2023 14:08:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z0P/9jB+wXlMbfjMCfJi+e0cOtQSlgwzrpAU70lmKor7BMF5iM55xG+caIqt3GsI/bz9zVMtotA7hgnXWFcVU65VSkyxtXoBDpwyRu4FG86h7/fKD38CxMdKD0PMJBhxCK867zLP6h+LEbFUoPY+8AwZ0cy1zsDk3DiCOuKSAgT0CTjH3IMU54Nu885Q0ojivx8K9kmJtttECRm/T090D8IL0AwL+NiI+VZaFgTgzbmVgOhi/Ip+NrlObKzWrOIKAwK/Y3SPFIDnBPziCyOfBSsTXM2OE7fEZyU20Vt2DUhgmoeh6o4CHf4BGnVlqnhSPOw0MKidKaTPxRdRP3i6Rw== 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=icpgXOYmCTgytcUVx7ePh3FLy7uSgM5uizRgCXv23QY=; b=ZWzTOKxBBACj3C6hqJV189SNq9QR8tnDzEeA55Qv4oMfD4vFobmbdo+TIHt4QhD1s7wxdTeE8SMDICrxMnqqCesxzILYnfUucRKNpjdr4wMoSR3yWOyFrizPtT07OA9ZAHKefPfSkr8DMEBvaGayvfg8Kxa/dnC9DAogTlVlcF/cKx4nYSB1WKRHfBEgcCibPcVf2KwEQggqfaRFu0OdWLNThJKaIja6f3grM7WDsihXzbrDM74xIodd4nayv2Hcf/aEYSP8wg4i7ZzeVTemHG7RoCi8CQubPIR03dRdGOiCKpSpkP4Kcmqn3O1jWejlKctkh741PL04cPUPuY3Sag== 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=icpgXOYmCTgytcUVx7ePh3FLy7uSgM5uizRgCXv23QY=; b=Uj710irO0aZkOXN0cFhtzK5705b0qXh0YySZW6INxCdHtEthbol+nNty6B8KvDpaBGjHj3HFRKJuiDBsU0uL05j5QqGDlXfhtUBU6mhfm2qu/oCW9f3P84fs1Gxlztf89ROst8eREfSZ+m2nxL3/nQn1i5+KuYi7qGgZwbk7slY= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by VE1PR08MB5792.eurprd08.prod.outlook.com (2603:10a6:800:1a6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26; Wed, 13 Dec 2023 14:08:36 +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.7091.022; Wed, 13 Dec 2023 14:08:36 +0000 From: Wilco Dijkstra To: 'GNU C Library' Subject: [PATCH v3 1/2] Add random benchmark Thread-Topic: [PATCH v3 1/2] Add random benchmark Thread-Index: AQHaLc3d7+GX4rulT0mwTpeK+Kmy+A== Date: Wed, 13 Dec 2023 14:08:36 +0000 Message-ID: References: In-Reply-To: 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_|VE1PR08MB5792:EE_|DB5PEPF00014B99:EE_|AS2PR08MB10226:EE_ X-MS-Office365-Filtering-Correlation-Id: c6236f50-d77a-4894-e68f-08dbfbe507b5 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: B9WKr5VeWGqZvvS1s6fC7OINGikpCurKx3SBfoXVIEAJM9H6kClkkuvP4b3Dvo/zWfMvsL/zxjwygdsp1pVq4nNZrI+UfmDHMloJ8xwzzGN2Z6uizFsam/B0xerv0i1ZCKSGRjKZ0Hlb1HSbuHqwFxWZ8MkGuscCKJaW+Xy3iYJ8P0LngDqkpjnwutc81t9izrRL/fhWKTGJxGJuNrmrk3shRwMuaZLQ++lGqOrVEJ1F40mVeuX0IB8pPYfFENFhXXwYVo78FGY8Fq3J7+EwaUymVJ1ZINnWBE6nbZ5grt2USXnSl2uU5J65Y0m/HtxGyETIT0o6DFbm8Xuox3prn08kD72vKqZFQ/h6Oy2nfd/FpzYFEEb9R0ErD5CWInbEJwTTI5tAQd1JEa3sK0MrBvMaVd2W0wvhptwO0xwy6I0lclWCCzHS5mIGDT7jgtDW35l4bL5VT19/bqSRMylMCXyhHFSl5gUVsQNYBFiyWuWYMLqaNxYreewFlgzzsj0vlS6wNCEterApooFlLTRP2npNciBeJOpX6CPR394vufhsmiq7lBcNQg6hz8qdCrJRF0qbgrQdqMQ74jlFUFDMor8mUHUpgD2RJ6e84kCLdmOB0MLSq4bt1tP+q9LBUSL/ 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)(39850400004)(396003)(376002)(346002)(366004)(136003)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(26005)(83380400001)(6506007)(9686003)(122000001)(7696005)(8676002)(38100700002)(5660300002)(8936002)(52536014)(41300700001)(2906002)(316002)(71200400001)(478600001)(66476007)(91956017)(64756008)(6916009)(66946007)(76116006)(66446008)(66556008)(33656002)(86362001)(38070700009)(55016003)(2004002); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5792 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: DB5PEPF00014B99.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 59318464-2f87-449d-5696-08dbfbe50003 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZzMRW8GTAdbtKCUaN6qafj1jYHw+ZTA7jy3sf1eGXBHDhHN0rAq/hUy+qUA80l6Redte3MoUtQbQF/Bm4gK3EvNUpk3adBpF3kKzW+3PTmSjsZ5Sx2Dmq3bfm5Yh/lH8xyO8Me3y8Wp1+4ch3iDmNi3mUyywhswZJ//uNsMCH3eZNbSHHwDRBuffCS3lz/1jwwmXW9IzBtIZyWgdyMFltVg/9435+JuBQ37ejY2xknr2LRnHN+9Ek+ko/gSOMzQz9ZWD2JSHokQAoTpbXcDe5qENIRMp5OSWuTp/fZoxBjAV4JlHJn1KTnWAiwIfDJR4Xc0J8ZGx0RFhs74JUVMw5QhKUJBMMi03x8ZoFowyiJi81rRJdlNhsXHb40v/T2USkWVQ+Yzy7A3yHpbEgZthXvwvD7bUHu2TpHGAhB2c2QDaXeF6gF0GJx4awmyFfAqxGkdDAecmb8THq0YoxVn/g/dCgidzMOc0ccgiB2XW3UpjZjJsfQFYGQe9UirL1JiXnsXtbmldgkekSD2oI2zX2MW6g+h8VrpLyRTNwHBEj6pncbyS392hKLcaYrnajHIQnTawlGgr5EFU+nRrBW97lIctk4I3NjRWBd0AiYgoQz+8ShrihBkU8/w2Gp+HsaffWx9sFUzaHJH9yO83TLEqcNcG2aBb5ziXwi1BhO496uC9C3hvxsXPBshHApe7kp5wWtFYDAV3VrHKRpm0JJPuoLJ8J88bhQq5Dx7lbEt0tWdqDMreIJNG1xxExI5wm6r3 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)(39860400002)(346002)(136003)(396003)(376002)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(40480700001)(36860700001)(52536014)(5660300002)(7696005)(40460700003)(41300700001)(47076005)(8936002)(81166007)(82740400003)(55016003)(356005)(2906002)(33656002)(86362001)(83380400001)(336012)(8676002)(70586007)(70206006)(6916009)(26005)(9686003)(478600001)(6506007)(316002)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2023 14:08:49.8345 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6236f50-d77a-4894-e68f-08dbfbe507b5 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: DB5PEPF00014B99.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10226 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"