Compare commits

..

No commits in common. "fe6dc1d84b2feea800fa95300190a478c19e3e70" and "5c90505fe7b6566049bead5e36a5e3f73d844413" have entirely different histories.

7 changed files with 86 additions and 92 deletions

0
src/Enums/Status.scala Normal file
View File

30
src/Main.scala Normal file
View File

@ -0,0 +1,30 @@
package com.nsrddyn
import com.nsrddyn.fpu.CholeskyDecomposition
import com.nsrddyn.Tests.CholeskyDecompositionTest
import java.time.Instant
import com.nsrddyn.alu.*
import com.nsrddyn.tools.Benchmark
enum Status:
case PASS
case FAIL
object Torque extends ZIOAppDefault {
println("hello world")
@main def main(args: String*): Unit = { println("\u001b[2J\u001b[H")
println("--- TORQUE STRESS TESTING UTILITY ---")
var tester: CholeskyDecompositionTest = new CholeskyDecompositionTest
println(tester.test())
}
var p: Prime = new Prime
p.run()
}

View File

@ -1,10 +1,8 @@
package main.Ops package com.nsrddyn.ops
import com.nsrddyn.tools.Benchmark
import main.tools.Benchmark
import main.Traits.*
import scala.util.hashing import scala.util.hashing
import scala.util.hashing.MurmurHash3 import scala.util.hashing.MurmurHash3
import com.nsrddyn.Traits.*
import scala.math._ import scala.math._
import scala.collection.immutable.ListSet import scala.collection.immutable.ListSet
import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArrayBuffer
@ -31,17 +29,47 @@ class Prime() {
* We want the function to be less optimized so that the CPU has more work == more stress * 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, result: Boolean): Unit = { def run(n: Int, result: Boolean): Unit = {
for i <- 0 to n do if isPrime(i) == result then println("true") else println("false") for i <- 0 to n do if isPrime(i) == result then println("true") else println("false")
} }
private def isPrime(n: Int): Boolean = {
if n <= 1 then false
else !(2 to math.sqrt(n).toInt).exists(i => n % i == 0)
}
} }
class PrimeRunner {
def run(threads: Int): Unit = {
val pr = new Prime()
val br = new Benchmark()
/*
* test cases
*
* 7919 true
* 2147483647 false
*/
val time = pr.run(7919, true)
println(time)
}
}
class Hash { class Hash {
def run(word: String, loopSize: Int): Unit = { def run(word: String, loopSize: Int): Unit = {

View File

@ -1,11 +1,18 @@
package main.Tests package com.nsrddyn.Tests
import com.nsrddyn.fpu.CholeskyDecomposition
import scala.collection.immutable.ListSet import scala.collection.immutable.ListSet
import zio._ import zio._
import main.Ops.CholeskyDecomposition
class TestsRunner extends ZIOAppDefault {
def run =
println("Hello world")
class CholeskyDecompositionRunner { }
class CholeskyDecompositionTest {
def test(): Unit = { def test(): Unit = {
@ -15,4 +22,7 @@ class CholeskyDecompositionRunner {
println(cdp.run(matrix)) println(cdp.run(matrix))
} }
} }

View File

@ -1,6 +1,4 @@
package main.tools package com.nsrddyn.tools
import main.Ops.*
class Benchmark { class Benchmark {
/* /*
@ -17,26 +15,3 @@ class Benchmark {
// TODO: map this to an actual precision value // TODO: map this to an actual precision value
def measurePrecision(work: => Boolean, expectedResult: Boolean): Unit = if work == expectedResult then println(true) else println(false) def measurePrecision(work: => Boolean, expectedResult: Boolean): Unit = if work == expectedResult then println(true) else println(false)
} }
class PrimeRunner {
def run(threads: Int): Unit = {
val pr = new Prime()
val br = new Benchmark()
/*
* test cases
*
* 7919 true
* 2147483647 false
*/
val time = pr.run(7919, true)
println(time)
}
}

View File

@ -1,10 +1,4 @@
package main.Traits package com.nsrddyn.Traits
import zio._
enum Status:
case PASS
case FAIL
trait Workload { trait Workload {

View File

@ -1,43 +0,0 @@
package main
import Ops.*
import Tests.*
import java.time.Instant
import zio._
/*
* *> = "Then" (think arrow pointing to what matters)
* <&> = "Both" (symbol looks like things going in both directions)
* <* = "Keep left" (pointing to what you keep)
* &> = "Keep right" (pointing to what you keep)
* */
object Torque extends ZIOAppDefault {
def runCholeskyTest: ZIO[Any, Throwable, Unit] =
ZIO.attempt {
val matrix: Vector[Vector[Int]] = Vector(Vector(1,2,3), Vector(1,2,3), Vector(1,2,3))
val cd = new CholeskyDecomposition
cd.run(matrix)
}.catchAll { error => Console.printError(s"failed: $error")}
def runPrimeTest: ZIO[Any, Throwable, Unit] =
ZIO.attempt {
val p = new Prime
p.run(390483094, true)
}.catchAll { error => Console.printError(s"failed: $error")}
def runSequential: ZIO[Any, Throwable, Unit] =
Console.printLine("sequential test") *>
runCholeskyTest *>
runPrimeTest
def runParallel: ZIO[Any, Throwable, Unit] =
Console.printLine("CholeskyTest") *>
(runCholeskyTest <&> runPrimeTest).unit
override def run: ZIO[ZIOAppArgs & Scope, Any, Any] = runParallel
}