9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] interesting timing tests
Date: Sun, 20 Jun 2010 21:41:44 -0400	[thread overview]
Message-ID: <81727c869e97f501968f868ee8794852@kw.quanstro.net> (raw)
In-Reply-To: <da2c7d30ad147fca47014c09d339aa1b@kw.quanstro.net>

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

oops.  botched fix of harmess warning.
corrected source attached.

just for a giggle, i ran this test on a few handy machines to get a feel
for relative speed of a single core.  since this test is small enough to
fit in the tiniest cache, i would think that memory speed or any other
external factor would be unimportant:

open rd/marvell kirkwood				471.97u 0.00s 472.25r
Intel(R) Atom(TM) CPU  330   @ 1.60GHz		48.47u 0.00s 48.48r
Intel(R) Pentium(R) 4 CPU 3.00GHz		40.72u 0.00s 40.76r
AMD Athlon(tm) 64 X2 Dual Core Processor 3800+	30.62u 0.00s 30.64r
AMD Athlon(tm) 64 X2 Dual Core Processor 5000+	23.18u 0.00s 23.19r
Intel(R) Xeon(R) CPU            5120  @ 1.86GHz	23.16u 0.00s 23.08r
Intel(R) Xeon(R) CPU           E5540  @ 2.53GHz	17.26u 0.00s 17.26r
Intel(R) Core(TM) i7 CPU         920  @ 2.67GHz	16.86u 0.00s 16.86r
Intel(R) Xeon(R) CPU           E5630  @ 2.53GHz	10.46u 0.00s 10.50r

perhaps the arm's vlong arithmitic isn't as well optimized as x86.  the
atom also is conspicuously slow, but unfortunately with no obvious
excuses.

- erik

[-- Attachment #2: burncycles.c --]
[-- Type: text/plain, Size: 814 bytes --]

#include <u.h>
#include <libc.h>
#include <thread.h>

#define Scale	(100000000000ull)

/*
 * waste time
 */
vlong
πjj(uint j)
{
	vlong v;

	v = 4*Scale / (2*j + 1);
	if(j&1)
		return -v;
	return v;
}

vlong
π(void)
{
	uint i;
	vlong v;

	v = 0;
	for(i = 0; i < 500000000; i++)
		v += πjj(i);
	return v;
}

void
p(void *v)
{
	int i;

	i = (int)v;
	print("%d: %lld\n", i, π());
	threadexits("");
}

void
usage(void)
{
	fprint(2, "usage: burncycles nthread\n");
	threadexits("usage");
}

void
threadmain(int argc, char **argv)
{
	int n, i;

	ARGBEGIN{
	default:
		usage();
	}ARGEND
	n = 0;
	if(argc == 0)
		n = 1;
	else if(argc != 1 || (n = atoi(argv[0])) <= 0)
		usage();
	for(i = 0; i < n-1; i++)
		proccreate(p, (void*)i, 4096);
	p((void*)i);
}

  reply	other threads:[~2010-06-21  1:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-18 23:26 erik quanstrom
2010-06-19 13:42 ` Richard Miller
2010-06-20  1:36   ` erik quanstrom
2010-06-20  7:44     ` Richard Miller
2010-06-20 12:45       ` erik quanstrom
2010-06-20 16:51         ` Richard Miller
2010-06-20 21:55           ` erik quanstrom
2010-06-21  1:41             ` erik quanstrom [this message]
2010-06-21  3:46               ` Venkatesh Srinivas
2010-06-21 14:40                 ` erik quanstrom
2010-06-21 16:42                   ` Venkatesh Srinivas
2010-06-21 16:43                   ` erik quanstrom
2010-06-21 21:11 ` Bakul Shah
2010-06-21 21:21   ` erik quanstrom
2010-06-21 21:47     ` Bakul Shah
2010-06-21 22:16       ` erik quanstrom
2010-06-22  3:24 ` Lawrence E. Bakst
2010-06-23  1:09   ` erik quanstrom

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=81727c869e97f501968f868ee8794852@kw.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).