diff options
| author | nasr <nsrddyn@gmail.com> | 2025-11-20 21:43:16 +0100 |
|---|---|---|
| committer | nasr <nsrddyn@gmail.com> | 2025-11-20 21:43:16 +0100 |
| commit | 409b76a88e589cbd7a8dfd9d0aad8152bb00d0bb (patch) | |
| tree | 6c6648a8bc025901e57de36174068ebd5e4a5523 /src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala | |
| parent | e077e179d43e04c7365acf8d1cc5bcb55998e6bd (diff) | |
feature: implemented some basic benchmarking logic & enum for pass and test
Diffstat (limited to 'src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala')
| -rw-r--r-- | src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala b/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala deleted file mode 100644 index effedef..0000000 --- a/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala +++ /dev/null @@ -1,45 +0,0 @@ -package com.nsrddyn.alu - - -import com.nsrddyn.tools.Benchmark - -class Prime() extends Benchmark: - - /* - * Calculate all primes up to limit - * This should stress the ALU in someway, - * doing this in a predictable manner, - * will hopefully keep the cpu pipeline busy - * and that way stress the branch predictor - * - * math.sqrt(n) => a prime number has 2 factors, one of the factors - * of the prime numbers has to be smaller then n - * after that we check if the number is whole number and thereby checking if its a prime - * - */ - - - /* - * TODO: I did the countrary of what i wanted to accieve with the is prime function - * We want the function to be less optimized so that the CPU has more work == more stress - */ - - - 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) - - - // 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 - } - |
