NovabenchParse.ps1


<#PSScriptInfo
 
.VERSION 1.0
 
.GUID 5afb9ad8-2529-4d30-a927-73451d707672
 
.AUTHOR dailen
 
.COMPANYNAME WideData Corporation
 
.COPYRIGHT 2025 (c) Dailen
 
.TAGS novabench specs benchmark dailen widedata
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
 
 
.PRIVATEDATA
 
#>


<#
 
.DESCRIPTION
  Converts Novabench CLI output into a PowerShell object.
 
#>
 
Param()


<#
.SYNOPSIS
Converts Novabench CLI output into a PowerShell object.
 
.DESCRIPTION
This function converts the output from the Novabench command-line
interface (CLI) into a PowerShell object with three properties:
 
* sysinfo: Contains system information (OS, CPU, GPU, Memory, Storage).
* testresults: Contains the overall Novabench score and
  individual component scores.
* teststats: Contains detailed test statistics for CPU, GPU, Memory,
  and Storage.
 
.PARAMETER Input
The Novabench CLI output as a string.
 
.EXAMPLE
$novabenchOutput = Get-Content -Path "novabench_results.txt" -Raw
$parsedOutput = $novabenchOutput | ConvertFrom-NovabenchOutput
 
.EXAMPLE
$novabenchOutput = novabench cli --run | Out-String
$parsedOutput = $novabenchOutput | ConvertFrom-NovabenchOutput
 
.NOTES
This function assumes the standard output format of the Novabench CLI.
 
.OUTPUTS
PSCustomObject
 
.LINK
https://novabench.com/
#>

function ConvertFrom-NovabenchOutput { 
  param (
      [Parameter(Mandatory, ValueFromPipeline)]
      [string]$Input
  )

  $output = @{}
  $currentSection = ""

  # Split the input string into lines
  $Input -split "`r`n" | ForEach-Object { 
      $line = $_.Trim()

      # Determine the current section of the output
      if ($line -match "^System Info:") {
          $currentSection = "sysinfo"
          $output["sysinfo"] = @{}
      } elseif ($line -match "^Test Results:") {
          $currentSection = "testresults"
          $output["testresults"] = @{}
      } elseif ($line -match "^-------------") {
          # Skip separator lines
      } elseif ($line -match "^\(CPU\)|\(GPU\)|\(Memory\)|\(Storage\)") {
          $currentSection = "teststats"
          if (-not $output.ContainsKey("teststats")) {
              $output["teststats"] = @{}
          }
          $parts = $line.Split(":")
          if ($parts.Count -eq 2) {
              $key = $parts[0].Trim()
              $value = $parts[1].Trim()
              $output["teststats"][$key] = $value
          }
      } elseif ($currentSection -eq "sysinfo" -and $line -match ":") {
          # Parse system info lines
          $parts = $line.Split(":")
          if ($parts.Count -eq 2) {
              $key = $parts[0].Trim()
              $value = $parts[1].Trim()
              $output["sysinfo"][$key] = $value
          }
      } elseif ($currentSection -eq "testresults" -and $line -match ":") {
          # Parse test results lines
          $parts = $line.Split(":")
          if ($parts.Count -eq 2) {
              $key = $parts[0].Trim()
              $value = $parts[1].Trim()
              $output["testresults"][$key] = $value
          }
      }
  }

  # Create and return the output object
  $obj = [PSCustomObject]$output
  return $obj
}