summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.sbt3
-rw-r--r--src/main/scala/main/Main.scala63
2 files changed, 53 insertions, 13 deletions
diff --git a/build.sbt b/build.sbt
index 8495493..f913f1f 100644
--- a/build.sbt
+++ b/build.sbt
@@ -4,3 +4,6 @@ name := "torque"
libraryDependencies += "dev.zio" %% "zio" % "2.1.22"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test
+// % ipv %% omdat het een java library is ipv scala
+libraryDependencies += "com.github.oshi" % "oshi-core" % "6.8.3"
+
diff --git a/src/main/scala/main/Main.scala b/src/main/scala/main/Main.scala
index 743084f..ebc82f0 100644
--- a/src/main/scala/main/Main.scala
+++ b/src/main/scala/main/Main.scala
@@ -2,7 +2,7 @@ package main
import Ops.*
import Tests.*
-
+import oshi._
import java.time.Instant
import zio._
@@ -16,28 +16,65 @@ import zio._
object Torque extends ZIOAppDefault {
- def runCholeskyTest: ZIO[Any, Throwable, Unit] =
+ // system resources
+ val si: SystemInfo = new SystemInfo
+ val sensors = si.getHardware.getSensors
+ val cpu = si.getHardware.getProcessor
+
+ // stress operations
+ val p = new Prime
+ val cd = new CholeskyDecomposition
+
+ def failSafe: Unit = while (true) do if sensors.getCpuTemperature > 80 then println("overheat")
+
+ 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)
+ //TODO: declare a randomized array to pass into the runner
+ // cd.run(matrix)
}.catchAll { error => Console.printError(s"failed: $error")}
- def runPrimeTest: ZIO[Any, Throwable, Unit] =
+ }
+
+ def runPrimeTest: ZIO[Any, Throwable, Unit] = {
ZIO.attempt {
- val p = new Prime
- p.run(390483094, true)
+ // p.run(390483094, true)
}.catchAll { error => Console.printError(s"failed: $error")}
+ }
+
+ def runSequential: ZIO[Any, Throwable, Unit] = {
- def runSequential: ZIO[Any, Throwable, Unit] =
Console.printLine("sequential test") *>
runCholeskyTest *>
runPrimeTest
+ }
+
+ def runParallel: ZIO[Any, Throwable, Unit] = {
- def runParallel: ZIO[Any, Throwable, Unit] =
- Console.printLine("CholeskyTest") *>
+ Console.printLine("CholeskyTest") *>
(runCholeskyTest <&> runPrimeTest).unit
+ }
- override def run: ZIO[ZIOAppArgs & Scope, Any, Any] = runParallel
-}
+ def getPlatform: ZIO[Any, Throwable, Unit] = {
+ ZIO.attempt {
+ println(si.getHardware)
+ }.catchAll { error => Console.printError(s"failed :$error")}
+ }
+ def getCpuFrequency: ZIO[Any, Throwable, Unit] = {
+ ZIO.attempt {
+ /*
+ * 227 oshi/hardware/CentralProcessor.java
+ * method takes long value as delay
+ * */
+ println("load: " + cpu.getSystemCpuLoad(1000) * 1000)
+ println("logical cores: " + cpu.getLogicalProcessorCount())
+ println("cores: " + cpu.getPhysicalProcessorCount())
+ println("temperature: " + sensors.getCpuTemperature())
+ }
+ }
+
+ def run: ZIO[ZIOAppArgs & Scope, Any, Any] = {
+ Console.printLine("=== TORQUE STRESS TEST ===") *> runParallel <*> getPlatform <*> getCpuFrequency
+ }
+}