Commit ef78506d authored by saad.aswad's avatar saad.aswad

Counters for contain and removing

parent d8f16659
......@@ -6,10 +6,7 @@
<component name="ChangeListManager">
<list default="true" id="3f4b2924-17d7-4794-bacf-d51c4f0be8bb" name="Changes" comment="List length, sorting in Adding implementations.">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/LockList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/LockList.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/RWLockList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/RWLockList.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/SortList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/SortList.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/SyncList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/SyncList.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/SyncListTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/SyncListTest.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
......@@ -46,20 +43,20 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"JUnit.SyncListTest.testRun.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "task2",
"kotlin-language-version-configured": "true",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.0"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;JUnit.SyncListTest.testRun.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;task2&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
&quot;project.structure.proportion&quot;: &quot;0.0&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.0&quot;
}
}]]></component>
}</component>
<component name="RunManager" selected="JUnit.SyncListTest.testRun">
<configuration name="SyncListTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="SortLinkedList" />
......
......@@ -3,10 +3,21 @@ public abstract class SortList {
public Entry head;
public long length;
public long conatinSuccess;
public long conatinFailure;
public long removeSuccess;
public long removeFailure;
public SortList() {
this.head = new Entry(Integer.MIN_VALUE);
this.head.next =new Entry(Integer.MAX_VALUE);
this.length = 2;
this.conatinSuccess=0;
this.conatinFailure=0;
this.removeFailure=0;
this.removeSuccess=0;
}
public abstract boolean add(Integer obj);
......
......@@ -32,6 +32,7 @@ public class SyncListTest extends TestCase {
List<Thread> addThreads = new ArrayList<>();
List<Thread> containThreads = new ArrayList<>();
List<Thread> removeThreads = new ArrayList<>();
for (int i = 0; i < 8; i++) {
AddThread addThread = new AddThread(seq, randLen / 8, list);
ContainThread containThread = new ContainThread(seq, randLen / 8, list);
......@@ -44,6 +45,9 @@ public class SyncListTest extends TestCase {
removeThreads.add(threadR);
}
// Add phase.
long startA = System.currentTimeMillis();
addThreads.stream().forEach(e -> e.start() );
......@@ -59,13 +63,14 @@ public class SyncListTest extends TestCase {
System.out.println("ADD "+label+" execution task: "+endA+" ms");
long listLengthAfterAdds = list.length;
System.out.println("Length of the list after adding: "+listLengthAfterAdds);
String listIsSorted = list.checkSorted() ? "The List is sorted" : "The list is not sorted";
System.out.println(listIsSorted);
// Contain phase.
long startC = System.currentTimeMillis();
containThreads.stream().forEach(e -> e.start() );
......@@ -83,6 +88,8 @@ public class SyncListTest extends TestCase {
System.out.println("Counter of Failure contain operations: "+list.conatinFailure);
// Remove phase.
long startR = System.currentTimeMillis();
removeThreads.stream().forEach(e -> e.start() );
......@@ -97,6 +104,16 @@ public class SyncListTest extends TestCase {
System.out.println("\nRemove "+label+" execution task: "+endR+" ms");
long listLengthAfterRemove = list.length;
System.out.println("Length of the list after removing: "+listLengthAfterRemove);
listIsSorted = list.checkSorted() ? "The List is sorted" : "The list is not sorted";
System.out.println(listIsSorted);
System.out.println("Counter of Success remove operations: "+list.removeSuccess);
System.out.println("Counter of Failure reomve operations: "+list.removeFailure);
}
public void testRun(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment