Commit 42e6fde7 authored by julanar.ali's avatar julanar.ali

Adding PrimerFinderTestClass

parent 543c3868
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -7,7 +7,13 @@ ...@@ -7,7 +7,13 @@
<groupId>org.example</groupId> <groupId>org.example</groupId>
<artifactId>PrimerFinder</artifactId> <artifactId>PrimerFinder</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
</dependencies>
<properties> <properties>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
......
package PrimerFinder;
import junit.framework.TestCase;
import java.util.List;
public class PrimerFinderTest extends TestCase {
public void testParallelPrimerFinder(){
int threadsNum=4;
int rangeStart = 1;
int rangeEnd = 100000000;
long starter= System.currentTimeMillis();
ParallelPrimerFinder parallelPrimerFinder=new ParallelPrimerFinder(threadsNum);
List<Integer> primes = parallelPrimerFinder.primesFinder(rangeStart,rangeEnd);
long end=System.currentTimeMillis();
System.out.println("Prime numbers between 1 and 100,000,000: ");
System.out.println( primes);
long time=end-starter;
System.out.println("The Time of finding Primes numbers between 1 and 100,000,000: "+time +" Millis");
}
}
...@@ -7,7 +7,7 @@ import java.util.List; ...@@ -7,7 +7,7 @@ import java.util.List;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
int threadsNum=100; /* int threadsNum=8;
int rangeStart = 1; int rangeStart = 1;
int rangeEnd = 100000000; int rangeEnd = 100000000;
long starter= System.currentTimeMillis(); long starter= System.currentTimeMillis();
...@@ -16,6 +16,6 @@ public class Main { ...@@ -16,6 +16,6 @@ public class Main {
long end=System.currentTimeMillis(); long end=System.currentTimeMillis();
System.out.println("Prime numbers between 1 and 100,000,000: " + primes); System.out.println("Prime numbers between 1 and 100,000,000: " + primes);
long time=end-starter; long time=end-starter;
System.out.println("The Time of finding Primes numbers between 1 and 100,000,000: "+time +" Millis"); System.out.println("The Time of finding Primes numbers between 1 and 100,000,000: "+time +" Millis");*/
} }
} }
\ No newline at end of file
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