WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] open/stat64 syscalls run faster on Xen VM than standard

To: xuehai zhang <hai@xxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] open/stat64 syscalls run faster on Xen VM than standard Linux
From: "Stephen C. Tweedie" <sct@xxxxxxxxxx>
Date: Mon, 28 Nov 2005 12:10:46 -0500
Cc: "Petersson, Mats" <mats.petersson@xxxxxxx>, Tim Freeman <tfreeman@xxxxxxxxxxx>, Kate Keahey <keahey@xxxxxxxxxxx>, Xen Mailing List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Mon, 28 Nov 2005 17:12:36 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <438B300A.8080209@xxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <907625E08839C4409CE5768403633E0B0EAAC4@xxxxxxxxxxxxxxxxx> <438B2753.4020401@xxxxxxxxxxxxxxx> <1133194042.3976.2.camel@xxxxxxxxxxxxxxxxxxxxx> <438B300A.8080209@xxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi,

On Mon, 2005-11-28 at 10:27 -0600, xuehai zhang wrote:

> Your questioning makes sense to me. But I am not very sure about how to 
> effectively count how many 
> these operations can be completed in a second. Can you give me some hint?

Here's a quick-and-dirty wrapper for timing "something" over the space
of a few seconds (default 10) and working out how fast it went.
Obviously, you want to be running this on an otherwise-idle machine, and
with CPU frequency management disabled.  It's really, really dumb, but
it only uses "time()", not any subsecond time sourcing, for its work.

Cheers,
 Stephen


#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>

#define TIME_SECS 10

static inline int time_is_before(time_t a, time_t b)
{
        return ((signed) (a-b)) < 0;
}

void timeme_noop(void)
{
        return;
}

void timeme_dosomething(void)
{
        struct stat statbuf;
        stat("/", &statbuf);
}

int run_time_loop(const char *what, void (*fn)(void))
{
        time_t end;
        int count=0;

        end = time(NULL) + TIME_SECS;

        printf("Timing %s for %d seconds: ", what, TIME_SECS);
        fflush(stdout);
        do {
                ++count;
                fn();
        } while (time_is_before(time(NULL), end));
        printf("completed %d cycles in %d seconds\n", count, TIME_SECS);
        return count;
}

void wait_for_tick(void)
{
        time_t end;
        printf("Waiting for fresh timer tick...");
        fflush(stdout);
        end = time(NULL) + 1;
        while (time_is_before(time(NULL), end));
        printf(" done.\n");
}

int main(void) 
{
        int loops_noop, loops_something;
        float how_long;
        
        wait_for_tick();
        loops_noop = run_time_loop("noop", timeme_noop);
        loops_something = run_time_loop("something", timeme_dosomething);

        how_long = 1.0 / ((float) (loops_noop - loops_something) / (TIME_SECS));
        printf ("Average time for something: %f seconds (%f ns).\n",
                how_long, how_long * 1000000000.0);
}

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>