mirror of
https://github.com/nasrlol/torque.git
synced 2025-11-27 23:09:21 +01:00
feature: implemented some basic benchmarking logic & enum for pass and test
This commit is contained in:
parent
e077e179d4
commit
409b76a88e
@ -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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
6
src/main/scala/com/nsrddyn/Enums/Status.scala
Normal file
6
src/main/scala/com/nsrddyn/Enums/Status.scala
Normal file
@ -0,0 +1,6 @@
|
||||
package com.nsrddyn.Enums
|
||||
|
||||
enum Status:
|
||||
case PASS
|
||||
case FAIL
|
||||
|
||||
@ -23,6 +23,4 @@ class CholeskyDecomposition {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user