summaryrefslogtreecommitdiff
path: root/src/main/scala/com/nsrddyn/cpu/ALU
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/com/nsrddyn/cpu/ALU')
-rw-r--r--src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala b/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala
index 3e6ad6f..47c83f1 100644
--- a/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala
+++ b/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala
@@ -1,9 +1,9 @@
-package com.nsrddyn
+package com.nsrddyn.alu
+import com.nsrddyn.tools.Measurable
-class Prime() {
-
+class Prime() extends Measurable:
/*
* Calculate all primes up to limit
@@ -18,11 +18,23 @@ class 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 = {
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 measure(): Long = {
+
+ // TODO: implement measure methode to measure the time that it takes to find that prime number
+ System.nanoTime()
+
+ }