summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornasr <nsrddyn@gmail.com>2025-12-01 18:35:59 +0100
committernasr <nsrddyn@gmail.com>2025-12-01 18:35:59 +0100
commit2a49df00757b5c62332d79ee99e8db250a825aba (patch)
treeca89b0f5625aaf5f949d74531faee54b652ec7d2 /src
parent2ec866b4787da9ad055b3582760764cc55918564 (diff)
feature: enhance resourceView output formatting and ensure execution flow
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/main/services/Stress.scala33
-rw-r--r--src/main/scala/main/view/View.scala22
2 files changed, 34 insertions, 21 deletions
diff --git a/src/main/scala/main/services/Stress.scala b/src/main/scala/main/services/Stress.scala
index dd74c9a..071fa8a 100644
--- a/src/main/scala/main/services/Stress.scala
+++ b/src/main/scala/main/services/Stress.scala
@@ -13,7 +13,8 @@ abstract class Stress {
}
-// TODO: program is exiting without completing the tests, my guess is it has something to do with ZIO Fiber forks
+// FOLLOW-UP NEEDED: program is exiting without completing the tests, my guess is it has something to do with ZIO Fiber forks
+// FOLLOW-UP: the tests are runnin, just getting an out of bounds exception when they do
class StressCpu() extends Stress {
override def runSequential: ZIO[Any, Throwable, Unit] = {
@@ -28,17 +29,6 @@ class StressCpu() extends Stress {
}
-
- def safety: ZIO[Unit, Throwable, Unit] = {
- val systemInfo = new SystemInfo
- val sensors = systemInfo.getHardware.getSensors
- ZIO.attempt {
- while (true) do
- if sensors.getCpuTemperature > 80 then println("overheat")
- }.catchAll { error => Console.printError(s"failed: $error") }
- }
-
-
def runCholeskyTest: ZIO[Any, Throwable, Unit] = {
val cd = new CholeskyDecomposition
ZIO
@@ -59,6 +49,18 @@ class StressCpu() extends Stress {
}
+
+ def safety: ZIO[Unit, Throwable, Unit] = {
+ val systemInfo = new SystemInfo
+ val sensors = systemInfo.getHardware.getSensors
+ ZIO.attempt {
+ while (true) do
+ if sensors.getCpuTemperature > 80 then println("overheat")
+ }.catchAll { error => Console.printError(s"failed: $error") }
+ }
+
+
+
}
class StressRam() extends Stress {
@@ -151,9 +153,10 @@ trait Runner {
def heavyRamRun: Task[Unit] = {
for {
- _ <- r.runParallel
- _ <- r.runSequential
- _ <- r.runParallel
+ par <- r.runParallel.fork
+ seq <- r.runSequential.fork
+ _ <- par.join
+ _ <- seq.join
} yield()
}
diff --git a/src/main/scala/main/view/View.scala b/src/main/scala/main/view/View.scala
index 3e60bf8..ce57d0f 100644
--- a/src/main/scala/main/view/View.scala
+++ b/src/main/scala/main/view/View.scala
@@ -82,11 +82,20 @@ class View extends Runner {
val sensors = hardware.getSensors
val cpu = hardware.getProcessor
- println("load: " + cpu.getSystemCpuLoad(1000) * 1000)
- println("logical cores: " + cpu.getLogicalProcessorCount())
- println("cores: " + cpu.getPhysicalProcessorCount())
- println("temperature: " + sensors.getCpuTemperature())
-
+ ZIO.attempt {
+ println(s"""
+ ===================================================
+ || CPU Load: ${cpu.getSystemCpuLoad(1000) * 100}%
+ || Logical Cores: ${cpu.getLogicalProcessorCount()}
+ || Physical Cores: ${cpu.getPhysicalProcessorCount()}
+ || Temperature: ${sensors.getCpuTemperature()}°C
+ || Total RAM: ${memory.getTotal() / (1024.0 * 1024 * 1024)} GB
+ || Available RAM: ${memory.getAvailable() / (1024.0 * 1024 * 1024)} GB
+ ===================================================
+ """.stripMargin)
+ pressToContinue
+ pressToContinue
+ }
}
@@ -126,12 +135,13 @@ class View extends Runner {
clearScreen
toInt(target) match {
- case 1 => lightCpuRun <&> ZIO.attempt { resourcesView }
+ case 1 => lightCpuRun
case 2 => heavyCpuRun
case 3 => lightCpuRun
case 4 => heavyCpuRun
}
+ resourcesView
}
def serveView: ZIO[Any, Throwable, Unit] = {