This commit is contained in:
		| @@ -17,30 +17,29 @@ 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) { | ||||||
|             println("Starting benchmark") |             val job = GlobalScope.launch { | ||||||
|             startTime = Instant.now() |                 println("Starting benchmark") | ||||||
|             while (elapsed < targetTime) { |                 startTime = Instant.now() | ||||||
|                 GlobalScope.launch { |                 while(elapsed < targetTime){ | ||||||
|                     uploader.uploadData(currIter, gson, cachedFile) |                     uploader.uploadData(currIter, gson, cachedFile) | ||||||
|  |                     currIter+=1 | ||||||
|  |                     currTimeStamp = Instant.now() | ||||||
|  |                     timestamps[currIter] = currTimeStamp | ||||||
|  |                     elapsed = Duration.between(startTime, currTimeStamp) | ||||||
|                 } |                 } | ||||||
|                 currIter += 1 |                 println("Benchmark ended") | ||||||
|                 currTimeStamp = Instant.now() |                 processResults.mapToProcess = timestamps | ||||||
|                 timestamps[currIter] = currTimeStamp |                 processResults.process() | ||||||
|                 elapsed = Duration.between(startTime, currTimeStamp) |  | ||||||
|             } |             } | ||||||
|             println("Benchmark ended") |  | ||||||
|             processResults.mapToProcess = timestamps |  | ||||||
|             processResults.process() |  | ||||||
|  |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user