Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moobench
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SustainKieker
moobench
Commits
d19d10d7
Commit
d19d10d7
authored
8 years ago
by
Christian Wulf
Browse files
Options
Downloads
Patches
Plain Diff
MooBench is now able to log the heap memory and gc collection count
parent
5d06c06d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.project
+7
-0
7 additions, 0 deletions
.project
src/mooBench/benchmark/BenchmarkingThreadNano.java
+19
-11
19 additions, 11 deletions
src/mooBench/benchmark/BenchmarkingThreadNano.java
with
26 additions
and
11 deletions
.project
+
7
−
0
View file @
d19d10d7
...
@@ -10,8 +10,15 @@
...
@@ -10,8 +10,15 @@
<arguments>
<arguments>
</arguments>
</arguments>
</buildCommand>
</buildCommand>
<buildCommand>
<name>
de.walware.statet.r.builders.RSupport
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
</buildSpec>
<natures>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
<nature>
org.eclipse.jdt.core.javanature
</nature>
<nature>
de.walware.statet.base.StatetNature
</nature>
<nature>
de.walware.statet.r.RNature
</nature>
</natures>
</natures>
</projectDescription>
</projectDescription>
This diff is collapsed.
Click to expand it.
src/mooBench/benchmark/BenchmarkingThreadNano.java
+
19
−
11
View file @
d19d10d7
...
@@ -35,11 +35,12 @@ public final class BenchmarkingThreadNano implements BenchmarkingThread {
...
@@ -35,11 +35,12 @@ public final class BenchmarkingThreadNano implements BenchmarkingThread {
private
final
long
methodTime
;
private
final
long
methodTime
;
private
final
int
recursionDepth
;
private
final
int
recursionDepth
;
private
final
long
[]
timing
s
;
private
final
long
[]
executionTime
s
;
private
final
long
[]
usedHeapMemory
;
private
final
MemoryMXBean
memory
;
private
final
MemoryMXBean
memory
;
private
final
long
[]
usedHeapMemory
;
private
final
long
[]
gcCollectionCountDiffs
;
private
final
List
<
GarbageCollectorMXBean
>
collector
;
private
final
List
<
GarbageCollectorMXBean
>
collector
;
public
BenchmarkingThreadNano
(
final
MonitoredClass
mc
,
final
int
totalCalls
,
public
BenchmarkingThreadNano
(
final
MonitoredClass
mc
,
final
int
totalCalls
,
...
@@ -50,40 +51,47 @@ public final class BenchmarkingThreadNano implements BenchmarkingThread {
...
@@ -50,40 +51,47 @@ public final class BenchmarkingThreadNano implements BenchmarkingThread {
this
.
methodTime
=
methodTime
;
this
.
methodTime
=
methodTime
;
this
.
recursionDepth
=
recursionDepth
;
this
.
recursionDepth
=
recursionDepth
;
// for monitoring execution times
// for monitoring execution times
this
.
timing
s
=
new
long
[
totalCalls
];
this
.
executionTime
s
=
new
long
[
totalCalls
];
// for monitoring memory consumption
// for monitoring memory consumption
this
.
memory
=
ManagementFactory
.
getMemoryMXBean
();
this
.
memory
=
ManagementFactory
.
getMemoryMXBean
();
this
.
usedHeapMemory
=
new
long
[
totalCalls
];
this
.
usedHeapMemory
=
new
long
[
totalCalls
];
// for monitoring the garbage collector
// for monitoring the garbage collector
this
.
gcCollectionCountDiffs
=
new
long
[
totalCalls
];
this
.
collector
=
ManagementFactory
.
getGarbageCollectorMXBeans
();
this
.
collector
=
ManagementFactory
.
getGarbageCollectorMXBeans
();
}
}
public
String
print
(
final
int
index
,
final
String
separatorString
)
{
public
String
print
(
final
int
index
,
final
String
separatorString
)
{
return
""
+
this
.
timings
[
index
]
/* + separatorString + this.usedHeapMemory[index] */
;
return
String
.
format
(
"%d%s%d%s%d"
,
this
.
executionTimes
[
index
],
separatorString
,
this
.
usedHeapMemory
[
index
],
separatorString
,
this
.
gcCollectionCountDiffs
[
index
]);
}
}
public
final
void
run
()
{
public
final
void
run
()
{
long
start_ns
;
long
start_ns
;
long
stop_ns
;
long
stop_ns
;
final
long
gcBefore
;
long
lastGcCount
=
this
.
computeGcCollectionCount
()
;
final
long
gcAfter
;
long
currentGcCount
;
for
(
int
i
=
0
;
i
<
this
.
totalCalls
;
i
++)
{
for
(
int
i
=
0
;
i
<
this
.
totalCalls
;
i
++)
{
// gcBefore = this.computeGcCollectionCount();
start_ns
=
this
.
getCurrentTimestamp
();
start_ns
=
this
.
getCurrentTimestamp
();
this
.
mc
.
monitoredMethod
(
this
.
methodTime
,
this
.
recursionDepth
);
this
.
mc
.
monitoredMethod
(
this
.
methodTime
,
this
.
recursionDepth
);
stop_ns
=
this
.
getCurrentTimestamp
();
stop_ns
=
this
.
getCurrentTimestamp
();
// gcAfter
= this.computeGcCollectionCount();
currentGcCount
=
this
.
computeGcCollectionCount
();
// save execution time
// save execution time
this
.
timings
[
i
]
=
stop_ns
-
start_ns
;
this
.
executionTimes
[
i
]
=
stop_ns
-
start_ns
;
// save heap memory
this
.
usedHeapMemory
[
i
]
=
this
.
memory
.
getHeapMemoryUsage
().
getUsed
();
// save gc collection count
this
.
gcCollectionCountDiffs
[
i
]
=
currentGcCount
-
lastGcCount
;
lastGcCount
=
currentGcCount
;
// print progress
if
((
i
%
100000
)
==
0
)
{
if
((
i
%
100000
)
==
0
)
{
System
.
out
.
println
(
i
);
// NOPMD (System.out)
System
.
out
.
println
(
i
);
// NOPMD (System.out)
}
}
// save heap memory
this
.
usedHeapMemory
[
i
]
=
this
.
memory
.
getHeapMemoryUsage
().
getUsed
();
}
}
this
.
doneSignal
.
countDown
();
this
.
doneSignal
.
countDown
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment