From a1334cca2601a08d156cad6eb73db11d5c7eebb7 Mon Sep 17 00:00:00 2001 From: lanarimarco Date: Wed, 18 Dec 2024 22:46:22 +0100 Subject: [PATCH] refactor: CLEARDS01 to DSPERF02 --- .../rpgparser/evaluation/DSPerformanceTest.kt | 25 +++++++++++++++++++ .../rpgparser/evaluation/InterpreterTest.kt | 21 ++-------------- .../{CLEARDS01.rpgle => DSPERF02.rpgle} | 0 3 files changed, 27 insertions(+), 19 deletions(-) rename rpgJavaInterpreter-core/src/test/resources/{CLEARDS01.rpgle => DSPERF02.rpgle} (100%) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/DSPerformanceTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/DSPerformanceTest.kt index e43e58fed..e88474a9c 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/DSPerformanceTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/DSPerformanceTest.kt @@ -18,10 +18,15 @@ package com.smeup.rpgparser.evaluation import com.smeup.rpgparser.AbstractTest import com.smeup.rpgparser.PerformanceTest +import com.smeup.rpgparser.execution.Configuration import com.smeup.rpgparser.jvminterop.JavaSystemInterface import org.junit.Test import org.junit.experimental.categories.Category +import java.time.Duration +import java.util.* import kotlin.test.assertTrue +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.DurationUnit open class DSPerformanceTest : AbstractTest() { @@ -45,4 +50,24 @@ open class DSPerformanceTest : AbstractTest() { assertTrue(performanceRatio > 10, "performanceRatio must be at least 10") } + + @Test + @Category(PerformanceTest::class) + fun executeDSPERF02() { + lateinit var start: Date + lateinit var end: Date + val configuration = Configuration().apply { + jarikoCallback.onEnterPgm = { _, _ -> + start = Date() + } + jarikoCallback.onExitPgm = { _, _, _ -> + end = Date() + } + } + "DSPERF02".outputOf(configuration = configuration) + val duration = Duration.between(start.toInstant(), end.toInstant()).toMillis().milliseconds + println(duration) + // Currently the assertion is really empirical + assertTrue(duration.toLong(DurationUnit.MILLISECONDS) < 1000, "Duration must be less than 1 second") + } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt index e777c02f3..fb524033c 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt @@ -5,13 +5,14 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * */ package com.smeup.rpgparser.evaluation @@ -30,12 +31,10 @@ import org.junit.Test import org.junit.experimental.categories.Category import java.math.BigDecimal import java.text.SimpleDateFormat -import java.time.Duration import java.time.LocalDate import java.time.format.DateTimeFormatter import java.util.* import kotlin.test.* -import kotlin.time.Duration.Companion.milliseconds open class InterpreterTest : AbstractTest() { @@ -2626,20 +2625,4 @@ Test 6 // Test that the program does not throw a NullPointerException "NULLPTR01".outputOf() } - - @Test - fun executeCLEARDS01() { - lateinit var start: Date - lateinit var end: Date - val configuration = Configuration().apply { - jarikoCallback.onEnterPgm = { _, _ -> - start = Date() - } - jarikoCallback.onExitPgm = { _, _, _ -> - end = Date() - } - } - "CLEARDS01".outputOf(configuration = configuration) - println(Duration.between(start.toInstant(), end.toInstant()).toMillis().milliseconds) - } } diff --git a/rpgJavaInterpreter-core/src/test/resources/CLEARDS01.rpgle b/rpgJavaInterpreter-core/src/test/resources/DSPERF02.rpgle similarity index 100% rename from rpgJavaInterpreter-core/src/test/resources/CLEARDS01.rpgle rename to rpgJavaInterpreter-core/src/test/resources/DSPERF02.rpgle