Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
eraser
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenLicht
eraser
Commits
30d19e5c
Commit
30d19e5c
authored
5 years ago
by
BBQ
Browse files
Options
Downloads
Patches
Plain Diff
add preference checking for benchmark
parent
9274f92d
No related branches found
No related tags found
1 merge request
!19
dev to master
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
benchmark/src/main/java/de/tudresden/inf/st/eraser/benchmark/Benchmark.java
+32
-16
32 additions, 16 deletions
.../java/de/tudresden/inf/st/eraser/benchmark/Benchmark.java
with
32 additions
and
16 deletions
benchmark/src/main/java/de/tudresden/inf/st/eraser/benchmark/Benchmark.java
+
32
−
16
View file @
30d19e5c
...
...
@@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.util.Arrays
;
...
...
@@ -69,7 +70,6 @@ public class Benchmark {
int
i
=
0
;
while
((
a_next_record
=
a_csv_reader
.
readNext
())!=
null
){
if
(
i
==
0
){
getCSVHeader
(
Arrays
.
copyOf
(
a_next_record
,
12
),
"a"
);
i
++;
}
...
...
@@ -86,11 +86,14 @@ public class Benchmark {
setNewValue
(
values1
,
PREFERENCE_ITEM_NAME
,
"preference"
);
// wait for 1s
try
{
Thread
.
sleep
(
TIME_PERIOD
);}
catch
(
InterruptedException
e
){
e
.
printStackTrace
();}
logger
.
warn
(
"checking/comparing the result from web server with the CSV"
);
HttpResponse
response
=
Request
.
Get
(
ACTIVITY_URL
).
execute
().
returnResponse
();
HttpResponse
response1
=
Request
.
Get
(
PREFERENCE_URL
).
execute
().
returnResponse
();
//check response
checkResult
(
response
,
a_next_record
);
checkResult
(
response1
,
p_next_record
);
checkResult
(
response
,
a_next_record
,
null
);
checkResult
(
response1
,
p_next_record
,
a_next_record
[
12
]);
logger
.
warn
(
"checking/comparing finised"
);
//logger.info("checking/comparing finished");
break
;
}
}
...
...
@@ -131,7 +134,8 @@ public class Benchmark {
.
bodyString
(
values
[
1
],
ContentType
.
TEXT_PLAIN
)
.
execute
().
returnResponse
();
String
put_response
=
httpResponse
.
getStatusLine
().
toString
();
if
(
put_response
.
contains
(
"200"
)){
logger
.
info
(
"put w_brightness to web server: response 200 ok"
);}
else
{
if
(
put_response
.
contains
(
"200"
)){
logger
.
info
(
"put preference input name: w_brightness, value : "
+
values
[
1
]+
" to web server: response 200 ok"
);}
else
{
logger
.
info
(
"can not put w_brightness to rest server"
);
}
}
catch
(
Exception
e
){
...
...
@@ -148,19 +152,18 @@ public class Benchmark {
PREFERENCE_ITEM_NAME
=
a_values
;
}
}
private
void
checkResult
(
HttpResponse
response
,
String
[]
record
){
private
void
checkResult
(
HttpResponse
response
,
String
[]
record
,
String
activity
){
int
status
=
response
.
getStatusLine
().
getStatusCode
();
if
(
status
==
200
&&
record
.
length
==
13
){
logger
.
info
(
"activity should be (read direct from CSV): "
+
record
[12]);
try
{
logger
.
info
(
EntityUtils
.
toString
(
response
.
getEntity
()));
logger
.
info
(
"get activity from web server: response 200 ok, value is: "
+
EntityUtils
.
toString
(
response
.
getEntity
()));
}
catch
(
IOException
e
){
e
.
printStackTrace
();
}
logger
.
info
(
"get activity from web server: response 200 ok"
);
}
else
if
(
status
==
200
&&
record
.
length
==
4
){
logger
.
info
(
"preference should be (read direct from CSV): "
+
get
Preference
(
record
));
logger
.
info
(
"preference should be (read direct from CSV): "
+
compare
Preference
Output
(
record
,
activity
));
try
{
logger
.
info
(
"get the iris1_item preference from web server: response 200 ok, value is: "
+
EntityUtils
.
toString
(
response
.
getEntity
()));
...
...
@@ -168,8 +171,7 @@ public class Benchmark {
e
.
printStackTrace
();
}
}
else
if
(
status
!=
200
&&
record
.
length
==
13
){
}
else
if
(
status
!=
200
&&
record
.
length
==
13
){
logger
.
info
(
"can not get the activity from the web server"
);
}
...
...
@@ -180,8 +182,22 @@ public class Benchmark {
}
}
private
String
getPreference
(
String
[]
record
){
return
""
;
private
String
comparePreferenceOutput
(
String
[]
record
,
String
activity
){
String
output
=
null
;
String
brightness
=
record
[1];
File
file
=
new
File
(
p_csv_file_path
);
FileReader
reader
;
CSVReader
csv_reader
;
try
{
reader
=
new
FileReader
(
file
);
csv_reader
=
new
CSVReader
(
reader
);
String
[]
next_record
;
while
((
next_record
=
csv_reader
.
readNext
())!=
null
){
if
(
next_record
[
0
].
equals
(
activity
)
&&
next_record
[
1
].
equals
(
brightness
)){
output
=
next_record
[
2
]+
",100,"
+
next_record
[
3
];
}
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();}
return
output
;
}
}
\ No newline at end of file
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