try it like this
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-10-22 02:46:57 +02:00
parent afdd1ee4eb
commit 233b706d29
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -17,22 +17,22 @@ fun Application.module(testing: Boolean = false) {
runBlocking { runBlocking {
val cachedFile = File("/app/wave.wav").readBytes() val cachedFile = File("/app/wave.wav").readBytes()
val gson = GsonBuilder().setPrettyPrinting().create() val gson = GsonBuilder().setPrettyPrinting().create()
var startTime : Instant var startTime: Instant
var elapsed = Duration.ofSeconds(0) var elapsed = Duration.ofSeconds(0)
val targetTime = Duration.ofSeconds(System.getenv("WAITTIME").toLong()) val targetTime = Duration.ofSeconds(System.getenv("WAITTIME").toLong())
var currIter = 1 var currIter = 1
val timestamps = LinkedHashMap<Int,Instant>() val timestamps = LinkedHashMap<Int, Instant>()
var currTimeStamp : Instant var currTimeStamp: Instant
val uploader = Uploader() val uploader = Uploader()
val processResults = ProcessResults() val processResults = ProcessResults()
environment.monitor.subscribe(ApplicationStarted) { environment.monitor.subscribe(ApplicationStarted) {
val job = GlobalScope.launch {
delay(3000L)
println("Starting benchmark") println("Starting benchmark")
startTime = Instant.now() startTime = Instant.now()
while(elapsed < targetTime){ while (elapsed < targetTime) {
GlobalScope.launch {
uploader.uploadData(currIter, gson, cachedFile) uploader.uploadData(currIter, gson, cachedFile)
currIter+=1 }
currIter += 1
currTimeStamp = Instant.now() currTimeStamp = Instant.now()
timestamps[currIter] = currTimeStamp timestamps[currIter] = currTimeStamp
elapsed = Duration.between(startTime, currTimeStamp) elapsed = Duration.between(startTime, currTimeStamp)
@ -40,7 +40,7 @@ fun Application.module(testing: Boolean = false) {
println("Benchmark ended") println("Benchmark ended")
processResults.mapToProcess = timestamps processResults.mapToProcess = timestamps
processResults.process() processResults.process()
}
} }
} }
} }