diff options
| author | nasr <nsrddyn@gmail.com> | 2025-11-28 00:41:59 +0100 |
|---|---|---|
| committer | nasr <nsrddyn@gmail.com> | 2025-11-28 00:41:59 +0100 |
| commit | eb6a89a1f4f9f5c10c3da312d58c72edd643fd4e (patch) | |
| tree | 1029816a73b8b343181f0458094fc300e351064a /src/main/scala | |
| parent | fe6dc1d84b2feea800fa95300190a478c19e3e70 (diff) | |
feature: oshi gathering basis system information, implemented basic temperature safe handling
Diffstat (limited to 'src/main/scala')
| -rw-r--r-- | src/main/scala/main/Main.scala | 63 |
1 files changed, 50 insertions, 13 deletions
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 + } +} |
