From patchwork Mon May 19 11:17:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 350211 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 24F8E140091 for ; Mon, 19 May 2014 21:16:13 +1000 (EST) 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:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=E5pk 3nyNB7zo5ttKfjONtYggewfPG0SAtrTvPATXL/tgcxdo4NM0WZ+3xXQPzUWF3q0h p+4hVy7YP1seL+khv/X9odRDZEZ9v6uGZA+/aLOWxj4xTjaPU2bkbG4lMdj7DuGP B9vftt/cq+YdqQs2/+TOBSuvzT7ytFj3QRFCDG0= 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:references :mime-version:content-type:in-reply-to; s=default; bh=STQNrz6a93 jSYxONu0QV3BJzOew=; b=Xro+XpaOcuwUUUrWEzHPj9m1mckAD97JO+kii6MpII a7q1ksZDwsChogXmUzc4rAuWESuUpDKaKiDAlrCC87WZPyoqeMQoF3t8GsRe+Nny 2+ILFae6wi9djq3YuonIAdsLv51uhI3sF6Q1xtDezAyn+mherGm+qTo1FMjJ68MU 8= Received: (qmail 3204 invoked by alias); 19 May 2014 11:16:07 -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 3190 invoked by uid 89); 19 May 2014 11:16:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Mon, 19 May 2014 16:47:15 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH v1.1] benchtests: Add new directive for benchmark initialization hook Message-ID: <20140519111714.GL13048@spoyarek.pnq.redhat.com> References: <20140519110833.GA952@spoyarek.pnq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140519110833.GA952@spoyarek.pnq.redhat.com> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) Sorry, I forgot to update this old patch before sending it. Here's the correct version. Siddhesh * benchtests/README: Document 'init' directive. * benchtests/bench-skeleton.c (main) [BENCH_INIT]: Call BENCH_INIT. * scripts/bench.py (gen_source): Define BENCH_INIT macro. (parse_file): Recognize 'init' directive. From 469da08fd32c5a38c0f8dcc985e0c2342bd729e3 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Sat, 22 Feb 2014 10:09:27 +0530 Subject: [PATCH] benchtests: Add new directive for benchmark initialization hook Add a new 'init' directive that specifies the name of the function to call to do function-specific initialization. This is useful for benchmarks that need to do a one-time initialization before the functions are executed. --- benchtests/README | 1 + benchtests/bench-skeleton.c | 3 +++ benchtests/scripts/bench.py | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/benchtests/README b/benchtests/README index 52a3cc2..999d268 100644 --- a/benchtests/README +++ b/benchtests/README @@ -62,6 +62,7 @@ one to add `foo' to the bench tests: and functions (specifically, this includes using "#include "source"). See pthread_once-inputs and pthreads_once-source.c for an example of how to use this to benchmark a function that needs state across several calls. + - init: Name of an initializer function to call to initialize the benchtest. - name: See following section for instructions on how to use this directive. Lines beginning with a single hash '#' are treated as comments. See diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c index 29d6bda..68a91dc 100644 --- a/benchtests/bench-skeleton.c +++ b/benchtests/bench-skeleton.c @@ -62,6 +62,9 @@ main (int argc, char **argv) unsigned long iters, res; +#ifdef BENCH_INIT + BENCH_INIT (); +#endif TIMING_INIT (res); iters = 1000 * res; diff --git a/benchtests/scripts/bench.py b/benchtests/scripts/bench.py index 492c764..eb5a141 100755 --- a/benchtests/scripts/bench.py +++ b/benchtests/scripts/bench.py @@ -128,6 +128,10 @@ def gen_source(func, directives, all_vals): else: getret = '' + # Test initialization. + if directives['init']: + print('#define BENCH_INIT %s' % directives['init']) + print(EPILOGUE % {'getret': getret, 'func': func}) @@ -232,7 +236,8 @@ def parse_file(func): 'args': [], 'includes': [], 'include-sources': [], - 'ret': '' + 'ret': '', + 'init': '' } try: