This commit is contained in:
		@@ -1,10 +1,8 @@
 | 
				
			|||||||
package com.kmlabz.k8s
 | 
					package com.kmlabz.k8s
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.google.gson.GsonBuilder
 | 
					 | 
				
			||||||
import io.ktor.application.*
 | 
					import io.ktor.application.*
 | 
				
			||||||
import io.ktor.util.*
 | 
					import io.ktor.util.*
 | 
				
			||||||
import kotlinx.coroutines.*
 | 
					import kotlinx.coroutines.*
 | 
				
			||||||
import java.io.File
 | 
					 | 
				
			||||||
import java.time.Duration
 | 
					import java.time.Duration
 | 
				
			||||||
import java.time.Instant
 | 
					import java.time.Instant
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -18,7 +16,7 @@ fun Application.module(testing: Boolean = false) {
 | 
				
			|||||||
        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 = 0
 | 
				
			||||||
        val timestamps = LinkedHashMap<Int, Instant>()
 | 
					        val timestamps = LinkedHashMap<Int, Instant>()
 | 
				
			||||||
        var currTimeStamp: Instant
 | 
					        var currTimeStamp: Instant
 | 
				
			||||||
        val uploader = Uploader()
 | 
					        val uploader = Uploader()
 | 
				
			||||||
@@ -27,17 +25,17 @@ fun Application.module(testing: Boolean = false) {
 | 
				
			|||||||
            println("Starting benchmark")
 | 
					            println("Starting benchmark")
 | 
				
			||||||
            startTime = Instant.now()
 | 
					            startTime = Instant.now()
 | 
				
			||||||
            while (elapsed < targetTime) {
 | 
					            while (elapsed < targetTime) {
 | 
				
			||||||
                val job = GlobalScope.launch {
 | 
					                currIter += 1
 | 
				
			||||||
 | 
					                GlobalScope.launch {
 | 
				
			||||||
                    uploader.uploadData(currIter)
 | 
					                    uploader.uploadData(currIter)
 | 
				
			||||||
                    currIter += 1
 | 
					 | 
				
			||||||
                    currTimeStamp = Instant.now()
 | 
					                    currTimeStamp = Instant.now()
 | 
				
			||||||
                    timestamps[currIter] = currTimeStamp
 | 
					                    timestamps[currIter] = currTimeStamp
 | 
				
			||||||
                    elapsed = Duration.between(startTime, currTimeStamp)
 | 
					                    elapsed = Duration.between(startTime, currTimeStamp)
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                println("Benchmark ended")
 | 
					 | 
				
			||||||
                processResults.mapToProcess = timestamps
 | 
					 | 
				
			||||||
                processResults.process()
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            println("Benchmark ended")
 | 
				
			||||||
 | 
					            processResults.mapToProcess = timestamps
 | 
				
			||||||
 | 
					            processResults.process()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user