Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
isochrone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institut für Informatik
dbis
dbis-isochrone
isochrone
Commits
c2d52314
Commit
c2d52314
authored
10 years ago
by
User expired
Browse files
Options
Downloads
Patches
Plain Diff
implemented graph creation for isochrone algorithm runtimes
parent
2c72cdaa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build.gradle
+1
-0
1 addition, 0 deletions
build.gradle
src/test/java/it/unibz/inf/isochrone/network/AlgorithmRuntimeTest.java
+88
-3
88 additions, 3 deletions
.../it/unibz/inf/isochrone/network/AlgorithmRuntimeTest.java
with
89 additions
and
3 deletions
build.gradle
+
1
−
0
View file @
c2d52314
...
@@ -142,6 +142,7 @@ dependencies {
...
@@ -142,6 +142,7 @@ dependencies {
runtime
'ch.qos.logback:logback-classic:1+'
runtime
'ch.qos.logback:logback-classic:1+'
testCompile
'org.testng:testng:6+'
testCompile
'org.testng:testng:6+'
testCompile
'net.sf.jchart2d:jchart2d:3+'
// testCompile 'org.apache.jmeter:ApacheJMeter:2.+'
// testCompile 'org.apache.jmeter:ApacheJMeter:2.+'
}
}
...
...
This diff is collapsed.
Click to expand it.
src/test/java/it/unibz/inf/isochrone/network/AlgorithmRuntimeTest.java
+
88
−
3
View file @
c2d52314
package
it.unibz.inf.isochrone.network
;
package
it.unibz.inf.isochrone.network
;
import
info.monitorenter.gui.chart.Chart2D
;
import
info.monitorenter.gui.chart.IAxis
;
import
info.monitorenter.gui.chart.IAxis.AxisTitle
;
import
info.monitorenter.gui.chart.ITrace2D
;
import
info.monitorenter.gui.chart.traces.Trace2DSimple
;
import
it.unibz.inf.isochrone.algorithm.Isochrone
;
import
it.unibz.inf.isochrone.algorithm.Isochrone
;
import
it.unibz.inf.isochrone.algorithm.MDijkstra
;
import
it.unibz.inf.isochrone.algorithm.MDijkstra
;
import
it.unibz.inf.isochrone.algorithm.MineX
;
import
it.unibz.inf.isochrone.algorithm.MineX
;
...
@@ -8,6 +13,9 @@ import it.unibz.inf.isochrone.config.ConfigDataset;
...
@@ -8,6 +13,9 @@ import it.unibz.inf.isochrone.config.ConfigDataset;
import
it.unibz.inf.isochrone.util.EnumContainer.Direction
;
import
it.unibz.inf.isochrone.util.EnumContainer.Direction
;
import
it.unibz.inf.isochrone.util.EnumContainer.Mode
;
import
it.unibz.inf.isochrone.util.EnumContainer.Mode
;
import
java.awt.BasicStroke
;
import
java.awt.Color
;
import
java.awt.Stroke
;
import
java.io.BufferedWriter
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -25,6 +33,8 @@ import java.util.Map.Entry;
...
@@ -25,6 +33,8 @@ import java.util.Map.Entry;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
java.util.TreeSet
;
import
javax.imageio.ImageIO
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.AfterClass
;
...
@@ -42,6 +52,7 @@ public final class AlgorithmRuntimeTest {
...
@@ -42,6 +52,7 @@ public final class AlgorithmRuntimeTest {
private
static
final
int
REPEAT_COUNT
=
5
;
private
static
final
int
REPEAT_COUNT
=
5
;
private
static
final
String
RESULTFILE_ENCODING
=
"UTF-8"
;
private
static
final
String
RESULTFILE_ENCODING
=
"UTF-8"
;
private
static
final
String
RESULTFILE_CSV_RUNTIME
=
"build/reports/tests/algorithm-runtimes.csv"
;
private
static
final
String
RESULTFILE_CSV_RUNTIME
=
"build/reports/tests/algorithm-runtimes.csv"
;
private
static
final
String
RESULTFILE_PNG_RUNTIME
=
"build/reports/tests/algorithm-runtimes.png"
;
private
static
final
String
RESULTFILE_XML_RUNTIME
=
"build/reports/tests/algorithm-runtimes.xml"
;
private
static
final
String
RESULTFILE_XML_RUNTIME
=
"build/reports/tests/algorithm-runtimes.xml"
;
private
static
final
int
[]
RUNTIME_OFFSETS
=
{
private
static
final
int
[]
RUNTIME_OFFSETS
=
{
60
,
// 1 minute (in sec)
60
,
// 1 minute (in sec)
...
@@ -105,8 +116,9 @@ public final class AlgorithmRuntimeTest {
...
@@ -105,8 +116,9 @@ public final class AlgorithmRuntimeTest {
@AfterClass
@AfterClass
public
void
writeRuntimes
()
{
public
void
writeRuntimes
()
{
writeRuntimeXML
();
writeRuntimeCSV
();
writeRuntimeCSV
();
writeRuntimePNG
();
writeRuntimeXML
();
}
}
@BeforeClass
(
alwaysRun
=
true
)
@BeforeClass
(
alwaysRun
=
true
)
...
@@ -257,7 +269,7 @@ public final class AlgorithmRuntimeTest {
...
@@ -257,7 +269,7 @@ public final class AlgorithmRuntimeTest {
final
Set
<
Entry
<
String
,
Long
>>
timeSet
=
results
.
entrySet
();
final
Set
<
Entry
<
String
,
Long
>>
timeSet
=
results
.
entrySet
();
final
Iterator
<
Entry
<
String
,
Long
>>
iter
=
timeSet
.
iterator
();
final
Iterator
<
Entry
<
String
,
Long
>>
iter
=
timeSet
.
iterator
();
while
(
iter
.
hasNext
())
{
while
(
iter
.
hasNext
())
{
fw
.
write
(
String
.
valueOf
(
iter
.
next
().
getValue
().
longValue
()
/
repeatCount
));
fw
.
write
(
String
.
valueOf
(
iter
.
next
().
getValue
().
longValue
()
/
(
double
)
repeatCount
));
if
(
iter
.
hasNext
())
{
if
(
iter
.
hasNext
())
{
fw
.
write
(
separator
);
fw
.
write
(
separator
);
}
}
...
@@ -271,6 +283,72 @@ public final class AlgorithmRuntimeTest {
...
@@ -271,6 +283,72 @@ public final class AlgorithmRuntimeTest {
}
}
}
}
private
static
void
writeMapToPNG
(
final
File
file
,
final
Set
<
Entry
<
String
,
Map
<
String
,
Long
>>>
resultSet
,
final
int
repeatCount
)
{
final
int
nrAlgorithms
=
resultSet
.
iterator
().
next
().
getValue
().
size
();
final
Map
<
String
,
ITrace2D
>
traceMap
=
new
HashMap
<>(
nrAlgorithms
);
final
Stroke
stroke
=
new
BasicStroke
(
3
);
final
Chart2D
chart
=
new
Chart2D
();
final
IAxis
<?>
axisX
=
chart
.
getAxisX
();
axisX
.
setAxisTitle
(
new
AxisTitle
(
"Isochrone runtime (sec)"
));
final
IAxis
<?>
axisY
=
chart
.
getAxisY
();
axisY
.
setAxisTitle
(
new
AxisTitle
(
"Time (msec)"
));
axisY
.
setPaintGrid
(
true
);
// Create colors
final
Color
[]
colorArr
=
new
Color
[
nrAlgorithms
];
for
(
int
i
=
0
;
i
<
nrAlgorithms
;
++
i
)
{
// CHECKSTYLE:OFF MagicNumber
colorArr
[
i
]
=
Color
.
getHSBColor
((
float
)
i
/
(
float
)
nrAlgorithms
,
0.85f
,
1.0f
);
// CHECKSTYLE:ON MagicNumber
}
int
nrAlgorithm
=
0
;
for
(
final
Entry
<
String
,
Map
<
String
,
Long
>>
runtimeEntry
:
resultSet
)
{
final
String
time
=
runtimeEntry
.
getKey
();
final
Map
<
String
,
Long
>
results
=
runtimeEntry
.
getValue
();
double
dmax
=
-
1
;
try
{
dmax
=
Float
.
parseFloat
(
time
);
}
catch
(
final
NumberFormatException
e
)
{
// runtime is not a number (most likely it is something like summed values... summed times will not be plotted)
continue
;
}
if
(
dmax
>
RUNTIME_OFFSETS
[
1
])
{
// only plot runtimes until first offset (because of axis scaling issues)
break
;
}
final
Set
<
Entry
<
String
,
Long
>>
timeSet
=
results
.
entrySet
();
for
(
final
Entry
<
String
,
Long
>
entry
:
timeSet
)
{
final
String
algorithmName
=
entry
.
getKey
();
final
double
runtime
=
entry
.
getValue
().
longValue
()
/
(
double
)
repeatCount
;
ITrace2D
trace
=
traceMap
.
get
(
algorithmName
);
if
(
trace
==
null
)
{
trace
=
new
Trace2DSimple
(
algorithmName
);
trace
.
setColor
(
colorArr
[
nrAlgorithm
++]);
trace
.
setStroke
(
stroke
);
traceMap
.
put
(
algorithmName
,
trace
);
chart
.
addTrace
(
trace
);
}
trace
.
addPoint
(
dmax
,
runtime
);
}
}
try
{
ImageIO
.
write
(
chart
.
snapShot
(),
"png"
,
new
File
(
RESULTFILE_PNG_RUNTIME
));
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
}
}
private
static
void
writeMapToXML
(
final
File
file
,
final
Set
<
Entry
<
String
,
Map
<
String
,
Long
>>>
resultSet
,
final
int
repeatCount
)
{
private
static
void
writeMapToXML
(
final
File
file
,
final
Set
<
Entry
<
String
,
Map
<
String
,
Long
>>>
resultSet
,
final
int
repeatCount
)
{
try
(
final
BufferedWriter
fw
=
new
BufferedWriter
(
new
PrintWriter
(
file
,
RESULTFILE_ENCODING
)))
{
try
(
final
BufferedWriter
fw
=
new
BufferedWriter
(
new
PrintWriter
(
file
,
RESULTFILE_ENCODING
)))
{
fw
.
write
(
"<?xml version=\"1.0\" encoding=\""
+
RESULTFILE_ENCODING
+
"\"?>"
);
fw
.
write
(
"<?xml version=\"1.0\" encoding=\""
+
RESULTFILE_ENCODING
+
"\"?>"
);
...
@@ -286,7 +364,9 @@ public final class AlgorithmRuntimeTest {
...
@@ -286,7 +364,9 @@ public final class AlgorithmRuntimeTest {
fw
.
newLine
();
fw
.
newLine
();
final
Set
<
Entry
<
String
,
Long
>>
timeSet
=
results
.
entrySet
();
final
Set
<
Entry
<
String
,
Long
>>
timeSet
=
results
.
entrySet
();
for
(
final
Entry
<
String
,
Long
>
entry
:
timeSet
)
{
for
(
final
Entry
<
String
,
Long
>
entry
:
timeSet
)
{
fw
.
write
(
"\t\t<"
+
entry
.
getKey
()
+
">"
+
entry
.
getValue
().
longValue
()
/
repeatCount
+
"</"
+
entry
.
getKey
()
+
">"
);
final
String
algorithmName
=
entry
.
getKey
();
final
double
runtime
=
entry
.
getValue
().
longValue
()
/
(
double
)
repeatCount
;
fw
.
write
(
"\t\t<"
+
algorithmName
+
">"
+
runtime
+
"</"
+
algorithmName
+
">"
);
fw
.
newLine
();
fw
.
newLine
();
}
}
fw
.
write
(
"\t</time_"
+
time
+
">"
);
fw
.
write
(
"\t</time_"
+
time
+
">"
);
...
@@ -305,6 +385,11 @@ public final class AlgorithmRuntimeTest {
...
@@ -305,6 +385,11 @@ public final class AlgorithmRuntimeTest {
writeMapToCSV
(
new
File
(
RESULTFILE_CSV_RUNTIME
),
resultSet
,
REPEAT_COUNT
);
writeMapToCSV
(
new
File
(
RESULTFILE_CSV_RUNTIME
),
resultSet
,
REPEAT_COUNT
);
}
}
private
static
void
writeRuntimePNG
()
{
final
Set
<
Entry
<
String
,
Map
<
String
,
Long
>>>
resultSet
=
runtimes
.
entrySet
();
writeMapToPNG
(
new
File
(
RESULTFILE_CSV_RUNTIME
),
resultSet
,
REPEAT_COUNT
);
}
private
static
void
writeRuntimeXML
()
{
private
static
void
writeRuntimeXML
()
{
final
Set
<
Entry
<
String
,
Map
<
String
,
Long
>>>
resultSet
=
runtimes
.
entrySet
();
final
Set
<
Entry
<
String
,
Map
<
String
,
Long
>>>
resultSet
=
runtimes
.
entrySet
();
writeMapToXML
(
new
File
(
RESULTFILE_XML_RUNTIME
),
resultSet
,
REPEAT_COUNT
);
writeMapToXML
(
new
File
(
RESULTFILE_XML_RUNTIME
),
resultSet
,
REPEAT_COUNT
);
...
...
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