From b024dca90f31aa2a4e6e384522e37ff10e6c6a70 Mon Sep 17 00:00:00 2001 From: franksn90 Date: Wed, 29 May 2024 14:59:12 +0200 Subject: [PATCH] Export now prints relative time as first column --- .../mosim/export/CSVFileExporter.kt | 12 +- src/test/resources/data_full_example.csv | 402 +++++++++--------- 2 files changed, 211 insertions(+), 203 deletions(-) diff --git a/src/main/kotlin/cambio/monitoring/mosim/export/CSVFileExporter.kt b/src/main/kotlin/cambio/monitoring/mosim/export/CSVFileExporter.kt index 4aaba03..b219fd9 100644 --- a/src/main/kotlin/cambio/monitoring/mosim/export/CSVFileExporter.kt +++ b/src/main/kotlin/cambio/monitoring/mosim/export/CSVFileExporter.kt @@ -10,6 +10,7 @@ import java.io.FileReader class CSVFileExporter(private val monitoringCSVLoc: String, private val config: SearchConfiguration) : Exporter { private val columnSeparator: String = "," + private val relativeTeamHeader = "time_relative" private data class MonitoringData( val headers: String, @@ -24,7 +25,7 @@ class CSVFileExporter(private val monitoringCSVLoc: String, private val config: val endValue = occurrence.value.second.time val (startIndex, endIndex) = findIndices(startValue, endValue, monitoringData) val writer = prepareOutputFile(occurrence.index) - writeMonitoringData(startIndex, endIndex, monitoringData, writer) + writeMonitoringData(startValue, startIndex, endIndex, monitoringData, writer) } } @@ -73,15 +74,22 @@ class CSVFileExporter(private val monitoringCSVLoc: String, private val config: } private fun writeMonitoringData( + startValue: Double, startIndex: Int, endIndex: Int, monitoringData: MonitoringData, writer: BufferedWriter ) { - writer.write(monitoringData.headers) + writer.write(relativeTeamHeader + columnSeparator + monitoringData.headers) val endIndexInclusive = (endIndex + 1).coerceAtMost(monitoringData.data.size) for (line in monitoringData.data.subList(startIndex, endIndexInclusive)) { + val valueInLine = line.split(columnSeparator) + val time = valueInLine[0].toDouble() + val relativeTime = time - startValue + writer.newLine() + writer.write(relativeTime.toString()) + writer.write(columnSeparator) writer.write(line) } writer.close() diff --git a/src/test/resources/data_full_example.csv b/src/test/resources/data_full_example.csv index f73cc15..d6113d3 100644 --- a/src/test/resources/data_full_example.csv +++ b/src/test/resources/data_full_example.csv @@ -1,201 +1,201 @@ -time, gateway.INTERNAL_DEP_ArrivalCount, example_service_InstanceCount -0, 2, 2 -1, 1, 2 -2, 2, 2 -3, 1, 2 -4, 2, 2 -5, 1, 2 -6, 1, 2 -7, 2, 2 -8, 1, 2 -9, 2, 2 -10, 1, 2 -11, 2, 2 -12, 2, 2 -13, 3, 2 -14, 2, 2 -15, 1, 2 -16, 2, 2 -17, 1, 2 -18, 1, 2 -19, 1, 2 -20, 2, 2 -21, 1, 2 -22, 2, 1 -23, 1, 1 -24, 3, 1 -25, 4, 1 -26, 3, 1 -27, 4, 1 -28, 4, 1 -29, 4, 1 -30, 3, 1 -31, 2, 2 -32, 3, 2 -33, 4, 2 -34, 4, 2 -35, 4, 2 -36, 3, 2 -37, 2, 2 -38, 4, 2 -39, 4, 2 -40, 3, 2 -41, 4, 2 -42, 3, 2 -43, 4, 2 -44, 5, 2 -45, 3, 2 -46, 5, 2 -47, 4, 2 -48, 5, 2 -49, 3, 2 -50, 4, 2 -51, 5, 2 -52, 8, 2 -53, 6, 2 -54, 7, 2 -55, 6, 2 -56, 6, 2 -57, 4, 2 -58, 1, 2 -59, 1, 2 -60, 1, 2 -61, 1, 2 -62, 1, 2 -63, 1, 2 -64, 1, 2 -65, 2, 2 -66, 1, 2 -67, 1, 2 -68, 2, 2 -69, 1, 2 -70, 1, 2 -71, 2, 1 -72, 1, 1 -73, 4, 1 -74, 5, 1 -75, 4, 1 -76, 5, 1 -77, 5, 1 -78, 6, 1 -79, 7, 1 -80, 8, 2 -81, 6, 2 -82, 7, 2 -83, 6, 2 -84, 7, 2 -85, 7, 2 -86, 6, 2 -87, 5, 2 -88, 6, 2 -89, 7, 2 -90, 8, 2 -91, 6, 2 -92, 7, 2 -93, 7, 2 -94, 8, 2 -95, 8, 2 -96, 7, 2 -97, 8, 2 -98, 9, 2 -99, 6, 2 -100, 7, 2 -101, 8, 2 -102, 6, 2 -103, 7, 2 -104, 6, 2 -105, 6, 2 -106, 4, 2 -107, 2, 2 -108, 1, 2 -109, 2, 2 -110, 1, 2 -111, 2, 2 -112, 2, 2 -113, 3, 2 -114, 2, 2 -115, 1, 2 -116, 2, 2 -117, 1, 2 -118, 1, 2 -119, 1, 2 -120, 2, 2 -121, 1, 2 -122, 1, 2 -123, 2, 2 -124, 1, 2 -125, 1, 2 -126, 2, 2 -127, 1, 2 -128, 1, 2 -129, 2, 2 -130, 1, 2 -131, 1, 2 -132, 2, 2 -133, 1, 2 -134, 1, 2 -135, 2, 2 -136, 1, 2 -137, 1, 2 -138, 2, 2 -139, 1, 2 -140, 1, 2 -141, 2, 2 -142, 1, 2 -143, 1, 2 -144, 2, 2 -145, 1, 2 -146, 1, 2 -147, 2, 2 -148, 1, 2 -149, 1, 2 -150, 2, 2 -151, 1, 2 -152, 1, 2 -153, 2, 2 -154, 1, 2 -155, 1, 2 -156, 2, 2 -157, 1, 2 -158, 1, 2 -159, 2, 2 -160, 1, 2 -161, 1, 2 -162, 2, 2 -163, 1, 2 -164, 1, 2 -165, 2, 2 -166, 1, 2 -167, 1, 2 -168, 2, 2 -169, 1, 2 -170, 1, 2 -171, 2, 2 -172, 1, 2 -173, 1, 2 -174, 2, 2 -175, 1, 2 -176, 1, 2 -177, 2, 2 -178, 1, 2 -179, 1, 2 -180, 2, 2 -181, 1, 2 -182, 1, 2 -183, 2, 2 -184, 1, 2 -185, 1, 2 -186, 2, 2 -187, 1, 2 -188, 1, 2 -189, 2, 2 -190, 1, 2 -191, 1, 2 -192, 2, 2 -193, 1, 2 -194, 1, 2 -195, 2, 2 -196, 1, 2 -197, 1, 2 -198, 2, 2 -199, 1, 2 \ No newline at end of file +time_original,gateway.INTERNAL_DEP_ArrivalCount,example_service_InstanceCount,AllResponseTimes +0,2,2,0.02 +1,1,2,0.03 +2,2,2,0.04 +3,1,2,0.02 +4,2,2,0.03 +5,1,2,0.02 +6,1,2,0.02 +7,2,2,0.02 +8,1,2,0.04 +9,2,2,0.02 +10,1,2,0.03 +11,2,2,0.03 +12,2,2,0.02 +13,3,2,0.02 +14,2,2,0.03 +15,1,2,0.03 +16,2,2,0.03 +17,1,2,0.01 +18,1,2,0.02 +19,1,2,0.02 +20,2,2,0.01 +21,1,2,0.02 +22,2,1,0.10 +23,1,1,0.90 +24,3,1,0.81 +25,4,1,0.50 +26,3,1,0.55 +27,4,1,0.48 +28,4,1,0.46 +29,4,1,0.47 +30,3,1,0.46 +31,2,2,0.39 +32,3,2,0.50 +33,4,2,0.47 +34,4,2,0.41 +35,4,2,0.35 +36,3,2,0.29 +37,2,2,0.20 +38,4,2,0.48 +39,4,2,0.42 +40,3,2,0.37 +41,4,2,0.58 +42,3,2,0.51 +43,4,2,0.55 +44,5,2,0.70 +45,3,2,0.87 +46,5,2,0.91 +47,4,2,0.93 +48,5,2,0.91 +49,3,2,0.88 +50,4,2,0.70 +51,5,2,0.71 +52,8,2,0.97 +53,6,2,0.95 +54,7,2,0.90 +55,6,2,0.89 +56,6,2,0.89 +57,4,2,0.91 +58,1,2,0.52 +59,1,2,0.26 +60,1,2,0.09 +61,1,2,0.03 +62,1,2,0.02 +63,1,2,0.03 +64,1,2,0.02 +65,2,2,0.05 +66,1,2,0.01 +67,1,2,0.03 +68,2,2,0.02 +69,1,2,0.05 +70,1,2,0.01 +71,2,1,0.35 +72,1,1,0.22 +73,4,1,0.81 +74,5,1,0.89 +75,4,1,0.92 +76,5,1,0.97 +77,5,1,0.98 +78,6,1,0.96 +79,7,1,0.97 +80,8,2,0.95 +81,6,2,0.89 +82,7,2,0.82 +83,6,2,0.79 +84,7,2,0.81 +85,7,2,0.82 +86,6,2,0.87 +87,5,2,0.75 +88,6,2,0.77 +89,7,2,0.76 +90,8,2,0.98 +91,6,2,0.88 +92,7,2,0.84 +93,7,2,0.82 +94,8,2,0.60 +95,8,2,0.82 +96,7,2,0.86 +97,8,2,0.82 +98,9,2,0.89 +99,6,2,0.90 +100,7,2,0.77 +101,8,2,0.86 +102,6,2,0.94 +103,7,2,0.68 +104,6,2,0.57 +105,6,2,0.59 +106,4,2,0.70 +107,2,2,0.54 +108,1,2,0.43 +109,2,2,0.24 +110,1,2,0.13 +111,2,2,0.04 +112,2,2,0.06 +113,3,2,0.07 +114,2,2,0.02 +115,1,2,0.01 +116,2,2,0.02 +117,1,2,0.03 +118,1,2,0.04 +119,1,2,0.03 +120,2,2,0.05 +121,1,2,0.01 +122,1,2,0.02 +123,2,2,0.04 +124,1,2,0.06 +125,1,2,0.07 +126,2,2,0.02 +127,1,2,0.01 +128,1,2,0.03 +129,2,2,0.02 +130,1,2,0.01 +131,1,2,0.05 +132,2,2,0.04 +133,1,2,0.03 +134,1,2,0.01 +135,2,2,0.04 +136,1,2,0.06 +137,1,2,0.09 +138,2,2,0.01 +139,1,2,0.05 +140,1,2,0.01 +141,2,2,0.02 +142,1,2,0.03 +143,1,2,0.04 +144,2,2,0.05 +145,1,2,0.03 +146,1,2,0.06 +147,2,2,0.07 +148,1,2,0.02 +149,1,2,0.03 +150,2,2,0.04 +151,1,2,0.05 +152,1,2,0.06 +153,2,2,0.01 +154,1,2,0.02 +155,1,2,0.06 +156,2,2,0.05 +157,1,2,0.06 +158,1,2,0.06 +159,2,2,0.04 +160,1,2,0.02 +161,1,2,0.04 +162,2,2,0.04 +163,1,2,0.03 +164,1,2,0.02 +165,2,2,0.02 +166,1,2,0.03 +167,1,2,0.01 +168,2,2,0.05 +169,1,2,0.03 +170,1,2,0.01 +171,2,2,0.03 +172,1,2,0.04 +173,1,2,0.03 +174,2,2,0.02 +175,1,2,0.01 +176,1,2,0.03 +177,2,2,0.02 +178,1,2,0.03 +179,1,2,0.02 +180,2,2,0.02 +181,1,2,0.01 +182,1,2,0.02 +183,2,2,0.03 +184,1,2,0.02 +185,1,2,0.30 +186,2,2,0.02 +187,1,2,0.03 +188,1,2,0.04 +189,2,2,0.05 +190,1,2,0.06 +191,1,2,0.03 +192,2,2,0.01 +193,1,2,0.02 +194,1,2,0.03 +195,2,2,0.01 +196,1,2,0.02 +197,1,2,0.03 +198,2,2,0.02 +199,1,2,0.03 \ No newline at end of file