Compare commits

..

No commits in common. "b3a5e3305a7f479aea0851a07e95b80088dd45e4" and "6114a98d542f38df7b16fe78ac115c42e34ec78c" have entirely different histories.

4 changed files with 17 additions and 62 deletions

View File

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

View File

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

View File

@ -4,28 +4,10 @@ import scala.util.hashing
class Hash {
import scala.util.hashing.MurmurHash3
def hashString(): Unit = {
def run(word: String, loopSize: Int): Unit = {
println("Hello from hash function")
/* 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,28 +1,5 @@
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)
}