From owner-freebsd-hackers@FreeBSD.ORG Tue Oct 5 22:29:32 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F37D3106566C for ; Tue, 5 Oct 2010 22:29:32 +0000 (UTC) (envelope-from giovanni.trematerra@gmail.com) Received: from mail-ww0-f42.google.com (mail-ww0-f42.google.com [74.125.82.42]) by mx1.freebsd.org (Postfix) with ESMTP id 8C78C8FC0A for ; Tue, 5 Oct 2010 22:29:32 +0000 (UTC) Received: by wwb13 with SMTP id 13so142036wwb.1 for ; Tue, 05 Oct 2010 15:29:31 -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=wFhlwHetkCJYvXczIOdEXJbbtXJlvWaS/xyHoPo9s9sV0JAJF4moPtYVq86TkkuAVq M4u8TUfUTpTbdhj46kHGUw4KLQyqwV17pVfiJUMF5/KrqsRKLsrGPT9SYLivDR72c5xI j4KcPp4YrC956SJDyHDsgY4quvyCYloEgvjVA= 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=mAe1Mohvk8oy/A+gu/XAkmU0Le9ponhwGlEP3x9OkOaICd4JACWc6l0v6qcDexGbKu o9R/tcQViMfsswX9DZ4zI9k+L1Gpm2Vq1pzvMO2KLGrR1bONieriN4nXGkbB37zKscsn afa2DfttW8QZzE1fYtFKBbERruz1npbSnOMlo= MIME-Version: 1.0 Received: by 10.227.129.12 with SMTP id m12mr10154449wbs.102.1286317770876; Tue, 05 Oct 2010 15:29:30 -0700 (PDT) Sender: giovanni.trematerra@gmail.com Received: by 10.227.144.203 with HTTP; Tue, 5 Oct 2010 15:29:30 -0700 (PDT) Date: Wed, 6 Oct 2010 00:29:30 +0200 X-Google-Sender-Auth: S7iyWq_zIwvvbRVmPq9btJ1JkZg Message-ID: From: Giovanni Trematerra To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: kernel micro-benchmarking framework X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Oct 2010 22:29:33 -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