l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
October 20: Web Application Hacking: How to Make and Break Security on the Web
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2006 Feb 17 19:29

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] benchmarking (again)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] benchmarking (again)



Peter Jay Salzman wrote:
I was under the impression that this is what computer scientists call
"locality of data" -- if data is used once, it'll be used again soon.  The
strategy that attempts to exploit locality of data is to hold recent data in
L1 cache.
The cache isn't under the programmer's direct control. It's a function of the hardware. The best the programmer can usually do is to try to access memory in ways that lets the cache work well. For example:

int array1[10000], array2[10000], array3[10000];

/* Version 1 */
for (i = 0; i < 10000; i++) {
sum1 += array1[i];
sum2 += array2[i];
sum3 += array3[i];
}

/* Version 2 */
for (i = 0; i < 10000; i++)
sum1 += array1[i];
for (i = 0; i < 10000; i++)
sum2 += array2[i];
for (i = 0; i < 10000; i++)
sum3 += array3[i];

You might expect version 1 to run faster because it has only one set of loop increment operations. But version 1 jumps among three widely separated memory blocks on each iteration, while version 2 accesses memory in a simple linear fashion. The latter is more cache-friendly. It might even run faster.


I see what you mean.  Yeah, but the question still remains -- what's going
on with the user time in java apps, and why does the program run faster in
Java than C++?  Certainly C++ compilers know how to do all that stuff too.
The code you're benchmarking doesn't have any side effects. Maybe the java compiler was smart enough to optimize the whole thing down to an empty function :-)
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.