I am trying to test the runtimes of various disk accessing patterns and have noticed that any time I use a randomly generated data set the execution takes roughly 2.5 times as long as usual, for both a cached and noncached access method. The non-cache, straight to disk, accesses have the same execution times for all of the other access patterns. The random accesses are the only ones that differ by a significant amount.
Is there a reason that the //testing stuff here section of my code runs slower when using accessPattern[i] = rand.nextInt(1000); rather than accessPattern[i] = i * 2;? I pass the elements of accessPattern[] one at a time to another function in the testing section, but I do not see why this would be affected by initializing the array using Random.
private void testRandomAccesses( ){
SysLib.cout( "Random Access Test\n" );
Random rand = new Random();
int accessPattern[] = new int[400];
for ( int i = 0; i < 400; ++i )
accessPattern[i] = rand.nextInt(1000); //slow execTime
//accessPattern[i] = i * 2; //fast execTime
startTime = new Date().getTime();
//testing stuff here
for ( int i = 0; i < 400; ++i )
SysLib.rawwrite( accessPattern[i], testBlock );
endTime = new Date().getTime();
execTime = endTime - startTime;
}
Aucun commentaire:
Enregistrer un commentaire