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
2b578911
Commit
2b578911
authored
Dec 11, 2018
by
Noric Couderc
Browse files
Added test to check the PAPI lib can be called.
parent
476014ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/ApplicationTest.java
View file @
2b578911
...
...
@@ -4,6 +4,9 @@ import se.lth.cs.*;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.*
;
import
papi.*
;
import
static
junit
.
framework
.
TestCase
.
assertEquals
;
public
class
ApplicationTest
{
...
...
@@ -140,4 +143,35 @@ public class ApplicationTest {
apps
);
}
@Test
public
void
TestPapi
()
throws
PapiException
{
Papi
.
init
();
// Throws exception
EventSet
evset
=
EventSet
.
create
(
Constants
.
PAPI_TOT_CYC
,
Constants
.
PAPI_L1_DCM
);
int
[]
results
=
new
int
[
10
];
// 9 warmup runs before measuring
for
(
int
warmup
=
10
;
warmup
>=
0
;
--
warmup
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
evset
.
start
();
// some weird code to measure
for
(
int
k
=
0
;
k
<=
i
*
10
;
k
++)
{
results
[
i
]
+=
k
*
k
;
}
// done with the code
evset
.
stop
();
long
[]
data
=
evset
.
getCounters
();
// only print the 10th run
if
(
warmup
==
0
)
{
System
.
out
.
println
(
"#"
+
i
+
":\t"
+
data
[
0
]
+
"\t"
+
data
[
1
]);
}
}
}
}
}
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