Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Noric Couderc
JBrainy
Commits
f8f59ea2
Commit
f8f59ea2
authored
Dec 22, 2021
by
Noric Couderc
Browse files
Fix: Tests for Timed Collections
Fixed the tests and usage of PAPI so it works on timed collections.
parent
e8dc9b5a
Changes
2
Show whitespace changes
Inline
Side-by-side
core/src/main/java/se/lth/cs/timing/CollectionTimer.java
View file @
f8f59ea2
...
...
@@ -68,6 +68,8 @@ public class CollectionTimer {
public
long
getCycles
(
OperationType
operationType
)
{
long
[]
readings
=
new
long
[
getEventSet
(
operationType
).
size
()];
getEventSet
(
operationType
).
read
(
readings
);
getEventSet
(
operationType
).
stop
();
getEventSet
(
operationType
).
reset
();
return
readings
[
0
];
}
...
...
@@ -117,6 +119,7 @@ public class CollectionTimer {
StopWatch
sw
=
getStopWatch
(
operationType
);
EventSet
ev
=
getEventSet
(
operationType
);
ev
.
reset
();
ev
.
start
();
if
(!
sw
.
isStarted
())
{
...
...
core/src/test/kotlin/StopWatchRunnerTest.kt
View file @
f8f59ea2
import
org.junit.FixMethodOrder
import
org.junit.jupiter.api.Assertions
import
org.junit.jupiter.api.BeforeEach
import
org.junit.jupiter.api.Test
import
org.junit.jupiter.params.ParameterizedTest
import
org.junit.jupiter.params.provider.Arguments
import
org.junit.jupiter.params.provider.MethodSource
import
org.junit.jupiter.params.provider.ValueSource
import
org.junit.runners.MethodSorters
import
papi.EventSet
import
se.lth.cs.bcgen.BCBenchmarkPackage
import
se.lth.cs.timing.StopWatchRunner
import
java.lang.RuntimeException
import
java.util.stream.Stream
class
StopWatchRunnerTest
{
...
...
@@ -16,13 +23,29 @@ class StopWatchRunnerTest {
Assertions
.
assertThrows
(
RuntimeException
::
class
.
java
)
{
s
.
timedDataStructure
(
"TimedLinkedList"
)}
}
companion
object
{
@JvmStatic
fun
makeArguments
():
Stream
<
Arguments
>
{
val
interfaces
=
listOf
<
String
>(
"LIST"
,
"SET"
,
"MAP"
)
val
seeds
=
listOf
<
Long
>(
1
,
2
,
3
,
4
,
5
)
val
result
=
mutableListOf
<
Arguments
>()
for
(
i
in
interfaces
)
{
for
(
s
in
seeds
)
{
result
.
add
(
Arguments
.
of
(
i
,
s
))
}
}
return
result
.
stream
()
}
}
@ParameterizedTest
()
@
Value
Source
(
strings
=
[
"LIST"
,
"SET"
,
"MAP"
]
)
fun
testGeneratedBenchmark
(
interfaceName
:
String
)
{
@
Method
Source
(
"makeArguments"
)
fun
testGeneratedBenchmark
(
interfaceName
:
String
,
seed
:
Long
)
{
val
bp
=
when
(
interfaceName
)
{
"LIST"
->
BCBenchmarkPackage
.
LIST
(
1234
,
100
,
0
,
ArrayList
<
Integer
>())
"MAP"
->
BCBenchmarkPackage
.
MAP
(
1234
,
100
,
0
,
HashMap
<
Integer
,
Integer
>())
"SET"
->
BCBenchmarkPackage
.
SET
(
1234
,
100
,
0
,
HashSet
<
Integer
>())
"LIST"
->
BCBenchmarkPackage
.
LIST
(
seed
.
toLong
()
,
100
,
0
,
ArrayList
<
Integer
>())
"MAP"
->
BCBenchmarkPackage
.
MAP
(
seed
.
toLong
()
,
100
,
0
,
HashMap
<
Integer
,
Integer
>())
"SET"
->
BCBenchmarkPackage
.
SET
(
seed
.
toLong
()
,
100
,
0
,
HashSet
<
Integer
>())
else
->
throw
RuntimeException
()
}
...
...
@@ -31,16 +54,16 @@ class StopWatchRunnerTest {
Assertions
.
assertEquals
(
4
,
counters
.
size
)
Assertions
.
assertEquals
(
"cyclesInsertions"
,
counters
[
0
].
stopWatchType
)
Assertions
.
assertTrue
(
counters
[
0
].
absolute
>
0
)
Assertions
.
assertTrue
(
counters
[
0
].
absolute
>
=
0
)
Assertions
.
assertEquals
(
"cyclesDeletions"
,
counters
[
1
].
stopWatchType
)
Assertions
.
assertTrue
(
counters
[
1
].
absolute
>
0
)
Assertions
.
assertTrue
(
counters
[
1
].
absolute
>
=
0
)
Assertions
.
assertEquals
(
"cyclesSearches"
,
counters
[
2
].
stopWatchType
)
Assertions
.
assertTrue
(
counters
[
2
].
absolute
>
0
)
Assertions
.
assertTrue
(
counters
[
2
].
absolute
>
=
0
)
Assertions
.
assertEquals
(
"cyclesIterations"
,
counters
[
3
].
stopWatchType
)
Assertions
.
assertTrue
(
counters
[
3
].
absolute
>
0
)
Assertions
.
assertTrue
(
counters
[
3
].
absolute
>
=
0
)
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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