This commit is contained in:
2026-02-11 17:52:11 +00:00
parent 11a64cdc1e
commit 93d29268dd
3 changed files with 166 additions and 1 deletions

View File

@@ -0,0 +1,83 @@
param(
[string]$BuildType = "roam" # roam or web
)
# -----------------------------
# CONFIG
# -----------------------------
$EmacsPath = "emacs" # or full path if needed
$LogDir = "$HOME/logs"
$Timestamp = (Get-Date).ToString("o")
if ($BuildType -eq "roam") {
$ElispFile = "$HOME/master-folder/org_files/org_roam/lisp/build.el"
$LogFile = "$LogDir/org-roam-resource.log"
}
elseif ($BuildType -eq "web") {
$ElispFile = "$HOME/master-folder/org_files/org_web/build-site.el"
$LogFile = "$LogDir/org-web-resource.log"
}
else {
Write-Host "Unknown build type"
exit 1
}
# -----------------------------
# START TIMER
# -----------------------------
$startTime = Get-Date
# Start Emacs process
$process = Start-Process `
-FilePath $EmacsPath `
-ArgumentList "--batch -l `"$ElispFile`"" `
-PassThru
# -----------------------------
# RESOURCE TRACKING LOOP
# -----------------------------
$cpuSamples = @()
$memSamples = @()
while (-not $process.HasExited) {
try {
$p = Get-Process -Id $process.Id -ErrorAction Stop
$cpuSamples += $p.CPU
$memSamples += $p.WorkingSet64
} catch {}
Start-Sleep -Milliseconds 500
}
$endTime = Get-Date
$duration = ($endTime - $startTime).TotalSeconds
# -----------------------------
# METRICS
# -----------------------------
$peakMemoryMB = [math]::Round(($memSamples | Measure-Object -Maximum).Maximum / 1MB, 2)
$avgMemoryMB = [math]::Round((($memSamples | Measure-Object -Average).Average) / 1MB, 2)
$totalCpu = ($cpuSamples | Measure-Object -Maximum).Maximum
# -----------------------------
# OUTPUT JSON
# -----------------------------
$result = @{
buildType = $BuildType
timestamp = $Timestamp
durationSec = [math]::Round($duration, 2)
peakMemoryMB = $peakMemoryMB
avgMemoryMB = $avgMemoryMB
cpuTime = $totalCpu
status = if ($process.ExitCode -eq 0) { "success" } else { "failure" }
}
$result | ConvertTo-Json | Out-File -FilePath $LogFile -Append
Write-Host "Build complete."
Write-Host "Duration: $duration seconds"
Write-Host "Peak Memory: $peakMemoryMB MB"

View File

@@ -0,0 +1,83 @@
param(
[string]$BuildType = "roam" # roam or web
)
# -----------------------------
# CONFIG
# -----------------------------
$EmacsPath = "emacs" # or full path if needed
$LogDir = "$HOME/logs"
$Timestamp = (Get-Date).ToString("o")
if ($BuildType -eq "roam") {
$ElispFile = "$HOME/master-folder/org_files/org_roam/build.el"
$LogFile = "$LogDir/org-roam-resource.log"
}
elseif ($BuildType -eq "web") {
$ElispFile = "$HOME/master-folder/org_files/org_web/build-site.el"
$LogFile = "$LogDir/org-web-resource.log"
}
else {
Write-Host "Unknown build type"
exit 1
}
# -----------------------------
# START TIMER
# -----------------------------
$startTime = Get-Date
# Start Emacs process
$process = Start-Process `
-FilePath $EmacsPath `
-ArgumentList "--batch -l `"$ElispFile`"" `
-PassThru
# -----------------------------
# RESOURCE TRACKING LOOP
# -----------------------------
$cpuSamples = @()
$memSamples = @()
while (-not $process.HasExited) {
try {
$p = Get-Process -Id $process.Id -ErrorAction Stop
$cpuSamples += $p.CPU
$memSamples += $p.WorkingSet64
} catch {}
Start-Sleep -Milliseconds 500
}
$endTime = Get-Date
$duration = ($endTime - $startTime).TotalSeconds
# -----------------------------
# METRICS
# -----------------------------
$peakMemoryMB = [math]::Round(($memSamples | Measure-Object -Maximum).Maximum / 1MB, 2)
$avgMemoryMB = [math]::Round((($memSamples | Measure-Object -Average).Average) / 1MB, 2)
$totalCpu = ($cpuSamples | Measure-Object -Maximum).Maximum
# -----------------------------
# OUTPUT JSON
# -----------------------------
$result = @{
buildType = $BuildType
timestamp = $Timestamp
durationSec = [math]::Round($duration, 2)
peakMemoryMB = $peakMemoryMB
avgMemoryMB = $avgMemoryMB
cpuTime = $totalCpu
status = if ($process.ExitCode -eq 0) { "success" } else { "failure" }
}
$result | ConvertTo-Json | Out-File -FilePath $LogFile -Append
Write-Host "Build complete."
Write-Host "Duration: $duration seconds"
Write-Host "Peak Memory: $peakMemoryMB MB"

View File

@@ -88,7 +88,6 @@ def format_ts(ts):
def delete_and_recreate_log_files():
log_files = [
CALIBRE_LOG,
ROAM_LOG,
WEB_LOG
]