Big honkin' merge from head. Sheesh!

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-08-27 01:01:30 +00:00
parent e2c66899cc
commit 8031cc6574
322 changed files with 20776 additions and 6550 deletions

View File

@@ -22,6 +22,9 @@ import java.io.FileOutputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashSet;
import java.util.Set;
import java.util.zip.CRC32;
import junit.framework.TestCase;
@@ -111,4 +114,30 @@ public class FileIOTest extends TestCase
countRead = channelRead.read(bufferRead);
assertEquals("Expected full read", 26, countRead);
}
public void testCrcPerformance() throws Exception
{
long before = System.nanoTime();
int count = 1000000;
Set<Long> results = new HashSet<Long>(count);
boolean negatives = false;
for (int i = 0; i < count; i++)
{
CRC32 crc = new CRC32();
crc.update(Integer.toString(i).getBytes());
long value = crc.getValue();
if (value < 0)
{
negatives = true;
}
if (!results.add(value))
{
System.out.println("Duplicate on " + i);
}
}
long after = System.nanoTime();
long delta = after - before;
double aveNs = (double)delta / (double)count;
System.out.println(String.format("CRC32: %10.2f ns per item. Negatives=" + negatives, aveNs));
}
}