From patchwork Mon May 19 11:08:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1008 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id C722A360079 for ; Mon, 19 May 2014 04:07:28 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14307373) id 73472571D621; Mon, 19 May 2014 04:07:28 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx22.g.dreamhost.com 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 homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 21B3A575018D for ; Mon, 19 May 2014 04:07:28 -0700 (PDT) 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:mime-version :content-type; q=dns; s=default; b=oH84xogq2Du2l6/6H/HRWXtlhwiiZ J6V/xm9wBSr+Lza2bTPoFRDOwt3Ut9o8PYfisPh0dabmHJS9kns8ra2z8YM0RGJ+ //FHxAe+a84DUdZyHJ0LAq8oo6Z0EcuQ4+puu96y5ZFoe5UkBkvC3N1pZUVKjxb6 HMEoZpb4HU1TCo= 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:mime-version :content-type; s=default; bh=l4vXxp5mmvM5/yT6jEhs4Kwps0Q=; b=nOg 8lyHslpIdm44jbr5qe9Ps+lG7ee/BpRjC+c+h757+epwZLq+c8XtrL8YATsFJ1la KCtbnsOXH/qX/68HSp+D8oO65P2tr0c9xPl5vw3Sme6srX9tG96V8dEpZMB8rWDP GcMgAR2pQ3a8yqIGtiTGTda8RAaekpFWmWrzC+JU= Received: (qmail 29302 invoked by alias); 19 May 2014 11:07:24 -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 29284 invoked by uid 89); 19 May 2014 11:07:23 -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:38:33 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH] benchtests: Add new directive for benchmark initialization hook Message-ID: <20140519110833.GA952@spoyarek.pnq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) X-DH-Original-To: glibc@patchwork.siddhesh.in 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. 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. --- benchtests/README | 1 + benchtests/bench-skeleton.c | 3 +++ scripts/bench.py | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/benchtests/README b/benchtests/README index 2a940fa..21ba995 100644 --- a/benchtests/README +++ b/benchtests/README @@ -60,6 +60,7 @@ one to add `foo' to the bench tests: - include-sources: This should be assigned a comma-separated list of source files that need to be included to provide definitions of global variables and functions (specifically, this includes using "#include "source"). + - 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 4290e76..53430d4 100644 --- a/benchtests/bench-skeleton.c +++ b/benchtests/bench-skeleton.c @@ -55,6 +55,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/scripts/bench.py b/scripts/bench.py index e500a33..064b64a 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -124,6 +124,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}) @@ -228,7 +232,8 @@ def parse_file(func): 'args': [], 'includes': [], 'include-sources': [], - 'ret': '' + 'ret': '', + 'init': '' } try: