Compare commits

...

4 Commits

Author SHA1 Message Date
b3a5e3305a feature: implemented hashing loop
- cleaned up useless ALU.scala file
- will not be passing threads as parameters
2025-11-19 00:58:59 +01:00
94e2465ded feature(updatefeature(update): prime calculation method
finished the prime number calculation method,  added an example of it
calculating the max int number. stresses cpu usage to 100%, not heavy
yet. But we are stressing it in someway. next steps are to add
multithreading and different ways of performance measurments.
2025-11-17 23:57:36 +01:00
a66ec9fb87 feature: calculating if a number is a prime
still not there yet, haven't figured out the functional programming
style of scala + have to find a way to make calculating primes a bit
heavier on the ALU, and stress the branch predictor aswell. Still
figuring stuff out.
2025-11-16 22:24:52 +01:00
e4e3a567ab refactor: scala 3 main function, call of the prime class 2025-11-16 22:23:30 +01:00
4 changed files with 62 additions and 17 deletions

View File

@ -1,10 +1,20 @@
package com.nsrddyn package com.nsrddyn
object Torque { object Torque {
def main(args: Array[String]): Unit = { import java.time.Instant
println("--- TORQUE STRESS TESTING UTILITY ---")
}
}
@main def main(args: String*): Unit =
// ANSI ESCAPE CODE: clear screen
println("\u001b[2J\u001b[H")
println("--- TORQUE STRESS TESTING UTILITY ---")
val now: Instant = Instant.now()
println(now)
val pr = new Prime()
val intMax = 2147483647
pr.run(intMax)
}

View File

@ -1,6 +0,0 @@
package com.nsrddyn
class ALU {
}

View File

@ -4,10 +4,28 @@ import scala.util.hashing
class Hash { class Hash {
def hashString(): Unit = { import scala.util.hashing.MurmurHash3
println("Hello from hash function") def run(word: String, loopSize: Int): Unit = {
/* TODO: implement ALU friendly, so high speed hashing
* to continuously loop over voor stressing
* ALU
*
* While looking for hashing algorithmes to implement I stumbled on:
* https://scala-lang.org/api/3.x/scala/util/hashing/MurmurHash3$.html
*
* which is an implemntation of **smasher** http://github.com/aappleby/smhasher
* the exact type of hashing algorithm I was looking for
*
* In the scala description they state: "This algorithm is designed to generate
* well-distributed non-cryptographic hashes. It is designed to hash data in 32 bit chunks (ints). "
*
* (ints) -> ALU
*
*/
for i <- 0 to loopSize do MurmurHash3.stringHash(word)
} }
} }

View File

@ -1,5 +1,28 @@
package com.nsrddyn package com.nsrddyn
class Prime {
class Prime() {
/*
* 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
*
*/
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)
} }