Permalink
Browse files

separate benchmarks from correctness tests which are now part of a ju…

…nit test suite integrated into the build system
  • Loading branch information...
d
d committed May 6, 2011
1 parent 267f35a commit 0503e7e7b08012fdc94892a00acbf879ad8f01e2
Showing with 701 additions and 308 deletions.
  1. +0 −6 Testing/NBHS_Tester/nbhs_tester.log
  2. +0 −191 Testing/NBHS_Tester/nbsi_tester.java
  3. +0 −6 Testing/NBHS_Tester/nbsi_tester.log
  4. +78 −53 build.xml
  5. +3 −2 ivy.xml
  6. +23 −19 ivysettings.xml
  7. 0 src/{ → main/java}/com/boundary/BitPrint.java
  8. 0 src/{ → main/java}/java/util/Hashtable.java
  9. 0 src/{ → main/java}/java/util/concurrent/ConcurrentHashMap.java
  10. 0 src/{ → main/java}/org/cliffc/high_scale_lib/AbstractEntry.java
  11. 0 src/{ → main/java}/org/cliffc/high_scale_lib/ConcurrentAutoTable.java
  12. 0 src/{ → main/java}/org/cliffc/high_scale_lib/Counter.java
  13. 0 src/{ → main/java}/org/cliffc/high_scale_lib/IntIterator.java
  14. 0 src/{ → main/java}/org/cliffc/high_scale_lib/NonBlockingHashMap.java
  15. 0 src/{ → main/java}/org/cliffc/high_scale_lib/NonBlockingHashMapLong.java
  16. 0 src/{ → main/java}/org/cliffc/high_scale_lib/NonBlockingHashSet.java
  17. 0 src/{ → main/java}/org/cliffc/high_scale_lib/NonBlockingHashtable.java
  18. 0 src/{ → main/java}/org/cliffc/high_scale_lib/NonBlockingIdentityHashMap.java
  19. +11 −10 src/{ → main/java}/org/cliffc/high_scale_lib/NonBlockingSetInt.java
  20. 0 src/{ → main/java}/org/cliffc/high_scale_lib/UtilUnsafe.java
  21. 0 {test/src → src/test}/java/com/boundary/BitPrintTest.java
  22. +20 −0 src/test/java/org/cliffc/high_scale_lib/HighScaleLibTestSuite.java
  23. +3 −5 ...ster/NBHML_Tester2.java → src/test/java/org/cliffc/high_scale_lib/NonBlockingHashMapLongTest.java
  24. +3 −5 ...HM_Tester/NBHM_Tester2.java → src/test/java/org/cliffc/high_scale_lib/NonBlockingHashMapTest.java
  25. +3 −5 ...BHS_Tester/nbhs_tester.java → src/test/java/org/cliffc/high_scale_lib/NonBlockingHashSetTest.java
  26. +551 −0 src/test/java/org/cliffc/high_scale_lib/NonBlockingIdentityHashMapTest.java
  27. +6 −6 {test/src → src/test}/java/org/cliffc/high_scale_lib/NonBlockingSetIntTest.java
@@ -1,6 +0,0 @@
-JUnit version 4.4
-....
-Time: 0.094
-
-OK (4 tests)
-
@@ -1,191 +0,0 @@
-/*
- * Written by Cliff Click and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- */
-
-import java.io.*;
-import java.util.*;
-import junit.framework.TestCase;
-import org.cliffc.high_scale_lib.*;
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-
-// Test NonBlockingSetInt via JUnit
-public class nbsi_tester extends TestCase {
- public static void main(String args[]) {
- org.junit.runner.JUnitCore.main("Testing.NBHS_Tester.nbsi_tester");
- }
-
- private NonBlockingSetInt _nbsi;
- protected void setUp () { _nbsi = new NonBlockingSetInt(); }
- protected void tearDown() { _nbsi = null; }
-
- // Test some basic stuff; add a few keys, remove a few keys
- public void testBasic() {
- assertTrue ( _nbsi.isEmpty() );
- assertTrue ( _nbsi.add(1) );
- checkSizes (1);
- assertTrue ( _nbsi.add(2) );
- checkSizes (2);
- assertFalse( _nbsi.add(1) );
- assertFalse( _nbsi.add(2) );
- checkSizes (2);
- assertThat ( _nbsi.remove(1), is(true ) );
- checkSizes (1);
- assertThat ( _nbsi.remove(1), is(false) );
- assertTrue ( _nbsi.remove(2) );
- checkSizes (0);
- assertFalse( _nbsi.remove(2) );
- assertFalse( _nbsi.remove(3) );
- assertTrue ( _nbsi.isEmpty() );
- assertTrue ( _nbsi.add(63) );
- checkSizes (1);
- assertTrue ( _nbsi.remove(63) );
- assertFalse( _nbsi.remove(63) );
-
-
- assertTrue ( _nbsi.isEmpty() );
- assertTrue ( _nbsi.add(10000) );
- checkSizes (1);
- assertTrue ( _nbsi.add(20000) );
- checkSizes (2);
- assertFalse( _nbsi.add(10000) );
- assertFalse( _nbsi.add(20000) );
- checkSizes (2);
- assertThat ( _nbsi.remove(10000), is(true ) );
- checkSizes (1);
- assertThat ( _nbsi.remove(10000), is(false) );
- assertTrue ( _nbsi.remove(20000) );
- checkSizes (0);
- assertFalse( _nbsi.remove(20000) );
- }
-
- // Check all iterators for correct size counts
- private void checkSizes(int expectedSize) {
- assertEquals( "size()", _nbsi.size(), expectedSize );
- Iterator it = _nbsi.iterator();
- int result = 0;
- while (it.hasNext()) {
- result++;
- it.next();
- }
- assertEquals( "iterator missed", expectedSize, result );
- }
-
-
- public void testIteration() {
- assertTrue ( _nbsi.isEmpty() );
- assertTrue ( _nbsi.add(1) );
- assertTrue ( _nbsi.add(2) );
-
- StringBuffer buf = new StringBuffer();
- for( Iterator<Integer> i = _nbsi.iterator(); i.hasNext(); ) {
- Integer val = i.next();
- buf.append(val);
- }
- assertThat("found all vals",buf.toString(),anyOf(is("12"),is("21")));
-
- assertThat("toString works",_nbsi.toString(), anyOf(is("[1, 2]"),is("[2, 1]")));
- }
-
- public void testIterationBig() {
- for( int i=0; i<100; i++ )
- _nbsi.add(i);
- assertThat( _nbsi.size(), is(100) );
-
- int sz =0;
- int sum = 0;
- for( Integer x : _nbsi ) {
- sz++;
- sum += x;
- assertTrue(x>=0 && x<=99);
- }
- assertThat("Found 100 ints",sz,is(100));
- assertThat("Found all integers in list",sum,is(100*99/2));
-
- assertThat( "can remove 3", _nbsi.remove(3), is(true) );
- assertThat( "can remove 4", _nbsi.remove(4), is(true) );
- sz =0;
- sum = 0;
- for( Integer x : _nbsi ) {
- sz++;
- sum += x;
- assertTrue(x>=0 && x<=99);
- }
- assertThat("Found 98 ints",sz,is(98));
- assertThat("Found all integers in list",sum,is(100*99/2 - (3+4)));
-
- }
-
- public void testSerial() {
- assertTrue ( _nbsi.isEmpty() );
- assertTrue ( _nbsi.add(1) );
- assertTrue ( _nbsi.add(2) );
-
- // Serialize it out
- try {
- FileOutputStream fos = new FileOutputStream("NBSI_test.txt");
- ObjectOutputStream out = new ObjectOutputStream(fos);
- out.writeObject(_nbsi);
- out.close();
- } catch(IOException ex) {
- ex.printStackTrace();
- }
-
- // Read it back
- try {
- File f = new File("NBSI_test.txt");
- FileInputStream fis = new FileInputStream(f);
- ObjectInputStream in = new ObjectInputStream(fis);
- NonBlockingSetInt nbsi = (NonBlockingSetInt)in.readObject();
- in.close();
- assertEquals(_nbsi.toString(),nbsi.toString());
- if( !f.delete() ) throw new IOException("delete failed");
- } catch(IOException ex) {
- ex.printStackTrace();
- } catch(ClassNotFoundException ex) {
- ex.printStackTrace();
- }
- }
-
- // Do some simple concurrent testing
- public void testConcurrentSimple() throws InterruptedException {
- final NonBlockingSetInt nbsi = new NonBlockingSetInt();
-
- // In 2 threads, add & remove even & odd elements concurrently
- Thread t1 = new Thread() { public void run() { work_helper(nbsi,"T1",1); } };
- t1.start();
- work_helper(nbsi,"T0",1);
- t1.join();
-
- // In the end, all members should be removed
- StringBuffer buf = new StringBuffer();
- buf.append("Should be emptyset but has these elements: {");
- boolean found = false;
- for( Integer x : nbsi ) {
- buf.append(" ").append(x);
- found = true;
- }
- if( found ) System.out.println(buf);
- assertThat( "concurrent size=0", nbsi.size(), is(0) );
- for( Integer x : nbsi ) {
- assertTrue("No elements so never get here",false);
- }
-
- }
-
- void work_helper(NonBlockingSetInt nbsi, String thrd, int d) {
- final int ITERS = 100000;
- for( int j=0; j<10; j++ ) {
- long start = System.nanoTime();
- for( int i=d; i<ITERS; i+=2 )
- nbsi.add(i);
- for( int i=d; i<ITERS; i+=2 )
- nbsi.remove(i);
- double delta_nanos = System.nanoTime()-start;
- double delta_secs = delta_nanos/1000000000.0;
- double ops = ITERS*2;
- //System.out.println("Thrd"+thrd+" "+(ops/delta_secs)+" ops/sec size="+nbsi.size());
- }
- }
-}
@@ -1,6 +0,0 @@
-JUnit version 4.4
-.....
-Time: 0.312
-
-OK (5 tests)
-
View
131 build.xml
@@ -1,97 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<project default="main" name="high-scale-lib" xmlns:ivy="antlib:org.apache.ivy.ant">
- <property name="ivy.version" value="2.2.0" />
- <property name="ivy.url"
- value="http://repo2.maven.org/maven2/org/apache/ivy/ivy" />
+ <property name="ivy.version" value="2.2.0" />
+ <property name="ivy.url"
+ value="http://repo2.maven.org/maven2/org/apache/ivy/ivy" />
<property file="publish.properties"/>
- <property name="basedir" value="."/>
- <property name="build.src" value="${basedir}/src"/>
- <property name="build.src.java" value="${basedir}/src/java"/>
- <property name="build.dir" value="${basedir}/build"/>
- <property name="build.dir.lib" value="${build.dir}/lib"/>
- <property name="build.classes" value="${build.dir}/classes"/>
- <property name="dist.dir" value="${build.dir}/dist"/>
-
- <path id="autoivy.classpath">
- <fileset dir="${build.dir.lib}">
- <include name="**/*.jar" />
- </fileset>
- <pathelement location="${build.dir}/ivy-${ivy.version}.jar"/>
- </path>
-
+ <property name="basedir" value="."/>
+ <property name="build.src" value="${basedir}/src"/>
+ <property name="build.src.java" value="${basedir}/src/main/java"/>
+ <property name="build.src.test.java" value="${basedir}/src/test/java"/>
+ <property name="build.dir" value="${basedir}/build"/>
+ <property name="build.dir.lib" value="${build.dir}/lib"/>
+ <property name="build.classes" value="${build.dir}/classes"/>
+ <property name="build.testclasses" value="${build.dir}/test-classes"/>
+ <property name="dist.dir" value="${build.dir}/dist"/>
+
+ <path id="autoivy.classpath">
+ <fileset dir="${build.dir.lib}">
+ <include name="**/*.jar" />
+ </fileset>
+ <pathelement location="${build.dir}/ivy-${ivy.version}.jar"/>
+ </path>
+
+ <path id="test.compile.classpath">
+ <path refid="autoivy.classpath"/>
+ <pathelement location="${build.classes}"/>
+ </path>
+
+ <path id="test.classpath">
+ <path refid="test.compile.classpath"/>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.testclasses}"/>
+ </path>
+
<target name="init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir.lib}"/>
<mkdir dir="${build.classes}"/>
+ <mkdir dir="${build.testclasses}"/>
<mkdir dir="${dist.dir}"/>
</target>
- <target name="ivy-download" depends="init" unless="ivy.jar.exists">
- <echo>Downloading Ivy...</echo>
- <get src="${ivy.url}/${ivy.version}/ivy-${ivy.version}.jar"
- dest="${build.dir.lib}/ivy-${ivy.version}.jar" usetimestamp="true" />
- </target>
-
- <target name="ivy-init" depends="ivy-download" unless="ivy.initialized">
- <taskdef resource="org/apache/ivy/ant/antlib.xml"
- uri="antlib:org.apache.ivy.ant"
- classpathref="autoivy.classpath"/>
- <property name="ivy.initialized" value="true"/>
- </target>
+ <target name="ivy-download" depends="init" unless="ivy.jar.exists">
+ <echo>Downloading Ivy...</echo>
+ <get src="${ivy.url}/${ivy.version}/ivy-${ivy.version}.jar"
+ dest="${build.dir.lib}/ivy-${ivy.version}.jar" usetimestamp="true" />
+ </target>
- <target name="ivy-retrieve-build" depends="ivy-init, resolve">
- <ivy:retrieve type="jar,source" sync="true"
- pattern="${build.dir.lib}/[type]s/[artifact]-[revision].[ext]" />
- </target>
+ <target name="ivy-init" depends="ivy-download" unless="ivy.initialized">
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant"
+ classpathref="autoivy.classpath"/>
+ <property name="ivy.initialized" value="true"/>
+ </target>
+
+ <target name="ivy-retrieve-build" depends="ivy-init, resolve">
+ <ivy:retrieve type="jar,source" pattern="${build.dir.lib}/[type]s/[artifact].[ext]"/>
+ </target>
<target name="resolve">
<ivy:resolve file="ivy.xml" revision="${version}"/>
</target>
- <target name="main" depends="compile, jar" description="Main target">
- <echo>
- Building the .jar file.
- </echo>
- </target>
-
- <target name="compile" depends="ivy-retrieve-build" description="Compilation target">
- <javac srcdir="src" destdir="${build.classes}"/>
- </target>
+ <target name="main" depends="compile, jar" description="Main target">
+ <echo>
+ Building the .jar file.
+ </echo>
+ </target>
+
+ <target name="compile" depends="ivy-retrieve-build" description="Compilation target">
+ <javac srcdir="${build.src.java}" destdir="${build.classes}"/>
+ </target>
<target name="gen-pom" depends="ivy-init">
- <ivy:makepom ivyfile="ivy.xml" pomfile="${dist.dir}/${ant.project.name}.pom">
- <mapping conf="default" scope="compile"/>
+ <ivy:makepom ivyfile="ivy.xml" pomfile="${dist.dir}/${ant.project.name}.pom">
+ <mapping conf="default" scope="compile"/>
</ivy:makepom>
</target>
<target name="jar" description="jar target" depends="compile">
- <jar jarfile="${dist.dir}/high-scale-lib.jar" basedir="${build.classes}" includes="org/**/*.class" />
+ <jar jarfile="${dist.dir}/high-scale-lib.jar" basedir="${build.classes}" includes="org/**/*.class" />
</target>
-
+
+ <target name="compile-tests" depends="compile">
+ <javac srcdir="${build.src.test.java}" destdir="${build.testclasses}">
+ <classpath refid="test.compile.classpath"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile-tests" description="run unit tests">
+ <junit>
+ <classpath refid="test.classpath"/>
+ <test name="org.cliffc.high_scale_lib.HighScaleLibTestSuite"/>
+ </junit>
+ </target>
+
<target name="publish" description="publish jar to artifactory" depends="jar, gen-pom">
- <ivy:publish resolver="artifactory-publish" overwrite="true" organisation="${organization}" module="${module}" revision="${version}">
+ <ivy:publish resolver="artifactory-publish" overwrite="true" organisation="${organization}" module="${module}" revision="${version}">
<artifacts pattern="${dist.dir}/[artifact].[ext]"/>
-
- <artifact name="${ivy.module}" ext="pom" type="pom"/>
+ <artifact name="${ivy.module}" ext="pom" type="pom"/>
</ivy:publish>
</target>
<target name="publish-local" description="publish jar to the local repo" depends="jar">
- <ivy:publish resolver="local" overwrite="true" organisation="${organization}" module="${module}" revision="${version}">
+ <ivy:publish resolver="local" overwrite="true" organisation="${organization}" module="${module}" revision="${version}">
<artifacts pattern="${dist.dir}/[artifact].[ext]"/>
</ivy:publish>
</target>
<target name="clean" description="get rid of any build artifacts">
<delete dir="${dist.dir}" />
<delete dir="${build.dir}" />
- <delete dir="doc" />
+ <delete dir="doc"/>
</target>
<target name="javadoc" description="generate the docs">
- <javadoc sourcepath="src" destdir="doc"/>
+ <javadoc sourcepath="src" destdir="doc"/>
</target>
</project>
View
@@ -1,7 +1,8 @@
<ivy-module version="2.0">
<info organisation="${organization}" module="${module}" revision="${version}"/>
-
<dependencies>
-
+ <dependency org="junit" name="junit" rev="4.8.2" >
+ <artifact name="junit" type="jar" conf="test"/>
+ </dependency>
</dependencies>
</ivy-module>
Oops, something went wrong.

0 comments on commit 0503e7e

Please sign in to comment.