From 5962a477f48aeff8ef835b2a48149674adf6e928 Mon Sep 17 00:00:00 2001 From: Torma Date: Thu, 22 Oct 2020 02:00:45 +0200 Subject: [PATCH] push it hard --- src/Application.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Application.kt b/src/Application.kt index 534f1c8..0d24600 100644 --- a/src/Application.kt +++ b/src/Application.kt @@ -12,19 +12,32 @@ import io.ktor.http.content.* import io.ktor.util.* import kotlinx.coroutines.* import java.io.File +import java.time.Duration +import java.time.Instant fun main(args: Array): Unit = io.ktor.server.tomcat.EngineMain.main(args) @KtorExperimentalAPI -@Suppress("unused") // Referenced in application.conf +@Suppress("unused") @kotlin.jvm.JvmOverloads fun Application.module(testing: Boolean = false) { runBlocking { val cachedFile = File("/app/wave.wav").readBytes() val gson = GsonBuilder().setPrettyPrinting().create() - uploadData(1, gson, cachedFile) + val startTime = Instant.now() + var elapsed = Duration.ofSeconds(0) + val targetTime = Duration.ofSeconds(10) + var currIter = 1 + val timestamps = LinkedHashMap() + var currTimeStamp = Instant.now() + while(elapsed > targetTime){ + uploadData(currIter, gson, cachedFile) + currIter+=1 + currTimeStamp = Instant.now() + timestamps[currIter] = currTimeStamp + elapsed = Duration.between(startTime, currTimeStamp) + } } - } @KtorExperimentalAPI