Skip to content

Commit

Permalink
refactor: CLEARDS01 to DSPERF02
Browse files Browse the repository at this point in the history
  • Loading branch information
lanarimarco committed Dec 18, 2024
1 parent 4a8675f commit a1334cc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {

Expand Down Expand Up @@ -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)
}
}

0 comments on commit a1334cc

Please sign in to comment.