feature: implemented some basic benchmarking logic & enum for pass and test

This commit is contained in:
Abdellah El Morabit 2025-11-20 21:43:16 +01:00
parent e077e179d4
commit 409b76a88e
7 changed files with 17 additions and 27 deletions

View File

@ -3,7 +3,7 @@ package com.nsrddyn.alu
import com.nsrddyn.tools.Benchmark
class Prime() extends Benchmark:
class Prime() extends Benchmark {
/*
* Calculate all primes up to limit
@ -26,20 +26,16 @@ class Prime() extends Benchmark:
def isPrime(n: Int): Boolean = {
val start = measure()
if n <= 1 then false
else !(2 to math.sqrt(n).toInt).exists(i => n % i == 0)
}
def run(n: Int): Unit = for i <- 0 to n do isPrime(i)
def run(n: Int, result: Boolean): Unit = {
for i <- 0 to n do if isPrime(i) == result then println("true") else println("false")
// TODO: implement measure methode to measure the time that it takes to find that prime number
def measure(): Long ={
val start = System.nanoTime()
System.nanoTime()
val end = System.nanoTime()
start - end
}
}

View File

@ -0,0 +1,6 @@
package com.nsrddyn.Enums
enum Status:
case PASS
case FAIL

View File

@ -8,19 +8,9 @@ object Torque {
@main def main(args: String*): Unit =
val pr = new Prime()
val br = new Benchmark()
// ANSI ESCAPE CODE: clear screen
println("\u001b[2J\u001b[H")
println("--- TORQUE STRESS TESTING UTILITY ---")
// val value = 2147483647
val value = 200000
val time = br.measure(pr.run(value))
println(time)
}
}