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:
December 2: Social Gathering
Next Installfest:
TBA
Latest News:
Nov. 18: Officers elected
Page last updated:
2006 Feb 17 19:29
Events
 Meetings
 Installfests
 Demos
 Photos
Services
 Library
 LERT
 Jobs
 Documents
Interact
 Mailing Lists
 - Search
 - Archives
 Chat (IRC)
 Social Networks
About Us
 Members
 Projects
 Testimonials
 Call for Speakers
 Why Not MS?
 Finances
 Sponsors

^Home
?Search
?News & RSS
?Calendar
@Contact Us
$Buy Stuff
=Printable


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
facebook
LUGOD Group 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
1105 Kennedy Place, Suite 1, Davis, CA 95616
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:
Sunset Systems
Who graciously hosts our website & mailing lists!