Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
E
Executor_Service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yazan.halloul
Executor_Service
Commits
1ee535dc
Commit
1ee535dc
authored
Nov 15, 2023
by
yazan.halloul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
junit test commit
parent
ad2914d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
ParallelCountersTest.java
src/test/java/ParallelCountersTest.java
+75
-0
No files found.
src/test/java/ParallelCountersTest.java
0 → 100644
View file @
1ee535dc
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
data.RangeArrayBuilder
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.Test
;
import
parallelCounters.*
;
class
ParallelCountersTest
{
private
static
int
start
;
private
static
int
finish
;
private
static
int
[]
data
;
private
static
long
result
;
@BeforeAll
public
static
void
initialize
()
{
start
=
0
;
finish
=
1000
;
data
=
RangeArrayBuilder
.
create
(
start
,
finish
);
result
=
SequentialCounter
.
findPrimeNumbers
(
data
);
}
private
static
void
testAll
(
int
threadCount
)
{
long
startTime
=
System
.
currentTimeMillis
();
long
actualResult0
=
ParallelCounter0
.
findPrimeNumbers
(
data
,
threadCount
);
long
actualResult1
=
ParallelCounter1
.
findPrimeNumbers
(
data
,
threadCount
);
long
actualResult2
=
ParallelCounter2
.
findPrimeNumbers
(
data
,
threadCount
);
long
actualResult3
=
ParallelCounter3
.
findPrimeNumbers
(
data
,
threadCount
);
long
actualResult4
=
ParallelCounter4
.
findPrimeNumbers
(
data
,
threadCount
);
long
endTime
=
System
.
currentTimeMillis
()
-
startTime
;
assertEquals
(
result
,
actualResult0
);
assertEquals
(
result
,
actualResult1
);
assertEquals
(
result
,
actualResult2
);
assertEquals
(
result
,
actualResult3
);
assertEquals
(
result
,
actualResult4
);
System
.
out
.
println
(
"Expected Result: "
+
result
);
System
.
out
.
println
(
"Actual Result in Parallel Counter 0: "
+
actualResult0
);
System
.
out
.
println
(
"Actual Result in Parallel Counter 1: "
+
actualResult1
);
System
.
out
.
println
(
"Actual Result in Parallel Counter 2: "
+
actualResult2
);
System
.
out
.
println
(
"Actual Result in Parallel Counter 3: "
+
actualResult3
);
System
.
out
.
println
(
"Actual Result in Parallel Counter 4: "
+
actualResult4
);
System
.
out
.
println
(
"Execute Time: "
+
endTime
);
}
@Test
void
testSingleThread
()
{
testAll
(
1
);
}
@Test
void
testTwoThread
()
{
testAll
(
2
);
}
@Test
void
testFourThread
()
{
testAll
(
4
);
}
@Test
void
testEightThread
()
{
testAll
(
8
);
}
@Test
void
testSixteenThread
()
{
testAll
(
16
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment