All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: xuehai zhang <hai@cs.uchicago.edu>
Cc: "Petersson, Mats" <mats.petersson@amd.com>,
	Tim Freeman <tfreeman@mcs.anl.gov>,
	Kate Keahey <keahey@mcs.anl.gov>,
	Xen Mailing List <xen-devel@lists.xensource.com>
Subject: Re: open/stat64 syscalls run faster on Xen VM than	standard Linux
Date: Mon, 28 Nov 2005 12:10:46 -0500	[thread overview]
Message-ID: <1133197846.3976.18.camel@orbit.scot.redhat.com> (raw)
In-Reply-To: <438B300A.8080209@cs.uchicago.edu>

[-- Attachment #1: Type: text/plain, Size: 609 bytes --]

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



[-- Attachment #2: Type: text/x-csrc, Size: 1269 bytes --]

#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);
}


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2005-11-28 17:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-28 14:45 open/stat64 syscalls run faster on Xen VM than standard Linux Petersson, Mats
2005-11-28 15:28 ` xuehai zhang
2005-11-28 15:50 ` xuehai zhang
2005-11-28 16:07   ` Stephen C. Tweedie
2005-11-28 16:27     ` xuehai zhang
2005-11-28 17:10       ` Stephen C. Tweedie [this message]
2005-11-29  4:50         ` Tim Freeman
2005-11-29 13:27         ` xuehai zhang
  -- strict thread matches above, loose matches on Subject: below --
2005-11-29 12:59 Petersson, Mats
2005-11-29 13:48 ` xuehai zhang
2005-11-28 18:17 Petersson, Mats
2005-11-28 16:15 Petersson, Mats
2005-11-28 17:16 ` xuehai zhang
2005-11-28 19:37   ` Anthony Liguori
2005-11-28 14:36 Petersson, Mats
2005-11-28 14:47 ` xuehai zhang
2005-11-28  8:21 xuehai zhang
2005-11-28 14:38 ` Anthony Liguori
2005-11-28 14:59   ` xuehai zhang
2005-11-29 12:39   ` xuehai zhang
2005-11-29 12:58     ` xuehai zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1133197846.3976.18.camel@orbit.scot.redhat.com \
    --to=sct@redhat.com \
    --cc=hai@cs.uchicago.edu \
    --cc=keahey@mcs.anl.gov \
    --cc=mats.petersson@amd.com \
    --cc=tfreeman@mcs.anl.gov \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.