From owner-freebsd-current@FreeBSD.ORG Tue Sep 28 21:14:03 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BDF8B106566B for ; Tue, 28 Sep 2010 21:14:03 +0000 (UTC) (envelope-from giovanni.trematerra@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 536418FC14 for ; Tue, 28 Sep 2010 21:14:02 +0000 (UTC) Received: by wwb17 with SMTP id 17so146668wwb.31 for ; Tue, 28 Sep 2010 14:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=vpudEbN478f0sSislrslp/TFTyRUHtm088WWIVsDQM8=; b=G9ZF3LGdneNGoo9mG7s4VAteOrFSKQFQuUeO3z/drnjz3wq6mcuZLIIzuVda7GrLe9 gqUlxc6SAIWG4cqM2HmhJBpqCcUDAZyzo1V7v95rU4WblDVXkFYJv+b2A/1+lZuyQNDK zBZMp1kfXehbGp3E+GbpXsd5Nh3zG/QgvcgLE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=d1vd3ofTYoNP/mWHiz5Jb3cdB2QQsvnaVxkYqsdvFSRevfQHyDYrl/bg/6HmNhqo8n myQGI3MNWet6Ah9GLgaoLywrWv7KQTzPHDI3H099ZLKvoAhWbU6s+K2ECtCFDAlBCqsn tC6l5HZKRdVv2wdUoOcYER/bwlbXb1YM+ZoQo= MIME-Version: 1.0 Received: by 10.227.152.18 with SMTP id e18mr564241wbw.1.1285706570044; Tue, 28 Sep 2010 13:42:50 -0700 (PDT) Sender: giovanni.trematerra@gmail.com Received: by 10.227.144.203 with HTTP; Tue, 28 Sep 2010 13:42:49 -0700 (PDT) Date: Tue, 28 Sep 2010 22:42:49 +0200 X-Google-Sender-Auth: Xy4xbKPUWlBETLO-ml_WSc1JQW4 Message-ID: From: Giovanni Trematerra To: FreeBSD Current Content-Type: text/plain; charset=ISO-8859-1 Subject: kernel micro-benchmarking framework X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Sep 2010 21:14:03 -0000 Hi all, based on a work of rwatson@ about micro-benchmarking, I managed to have a kernel module that exposes some sysctls. Reading sysctl associated to test start the benchmark and print the results. The code is split up in this way: test.h, test.c where the infrastructure work lives. test_sync_timing.c test_mem_timing.c where the actual micro-benchmarks live: I wrote some macros to simplify adding more benchmarks. (test.h) The idea is to have a struct for every benchmark/test struct timing_proc { void (*setup)(void *); /* called before starting timing */ void (*test)(void *); /* what we want microbenchmark */ void (*tear_down)(void *); /* called after the end of timing */ void *args; /* pointer passed to the above funcs */ }; and let an agnostic code deals with it. Every test can specify a setup and tear_down function for allocate/deallocate resources and a test function to benchmark things. The great difference with Robert's code is that the test function cannot be inline as it's a pointer to function. I don't know if that could influence the results. The test function is called with interrupt disabled. We could further extent this framework to add regression test support. You could get the code here: http://www.trematerra.net/patches/timing.tbz Feedback and reviews are welcome. Thanks -- Gianni