From 9968ac3dccd46df45e5a3a7c3e107b652b4ce83c Mon Sep 17 00:00:00 2001 From: Beingpax Date: Fri, 11 Jul 2025 19:11:34 +0545 Subject: [PATCH] Add sysmte info in analysis view --- VoiceInk.xcodeproj/project.pbxproj | 8 +- .../Metrics/PerformanceAnalysisView.swift | 85 ++++++++++++++++++- 2 files changed, 87 insertions(+), 6 deletions(-) diff --git a/VoiceInk.xcodeproj/project.pbxproj b/VoiceInk.xcodeproj/project.pbxproj index b7ac59f..9c7aea1 100644 --- a/VoiceInk.xcodeproj/project.pbxproj +++ b/VoiceInk.xcodeproj/project.pbxproj @@ -446,7 +446,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 138; + CURRENT_PROJECT_VERSION = 140; DEVELOPMENT_ASSET_PATHS = "\"VoiceInk/Preview Content\""; DEVELOPMENT_TEAM = V6J6A3VWY2; ENABLE_HARDENED_RUNTIME = YES; @@ -461,7 +461,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 1.38; + MARKETING_VERSION = 1.40; PRODUCT_BUNDLE_IDENTIFIER = com.prakashjoshipax.VoiceInk; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -479,7 +479,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 138; + CURRENT_PROJECT_VERSION = 140; DEVELOPMENT_ASSET_PATHS = "\"VoiceInk/Preview Content\""; DEVELOPMENT_TEAM = V6J6A3VWY2; ENABLE_HARDENED_RUNTIME = YES; @@ -494,7 +494,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 1.38; + MARKETING_VERSION = 1.40; PRODUCT_BUNDLE_IDENTIFIER = com.prakashjoshipax.VoiceInk; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/VoiceInk/Views/Metrics/PerformanceAnalysisView.swift b/VoiceInk/Views/Metrics/PerformanceAnalysisView.swift index 64dc930..09d4ff4 100644 --- a/VoiceInk/Views/Metrics/PerformanceAnalysisView.swift +++ b/VoiceInk/Views/Metrics/PerformanceAnalysisView.swift @@ -21,6 +21,8 @@ struct PerformanceAnalysisView: View { VStack(alignment: .leading, spacing: 30) { summarySection + systemInfoSection + if !analysis.transcriptionModels.isEmpty { transcriptionPerformanceSection } @@ -32,13 +34,13 @@ struct PerformanceAnalysisView: View { .padding() } } - .frame(minWidth: 550, idealWidth: 600, maxWidth: 700, minHeight: 450, idealHeight: 600, maxHeight: 800) + .frame(minWidth: 550, idealWidth: 600, maxWidth: 700, minHeight: 600, idealHeight: 750, maxHeight: 900) .background(Color(.windowBackgroundColor)) } private var header: some View { HStack { - Text("Performance Benchmark") + Text("Performance Analysis") .font(.title2) .fontWeight(.bold) Spacer() @@ -74,6 +76,20 @@ struct PerformanceAnalysisView: View { } } + private var systemInfoSection: some View { + VStack(alignment: .leading, spacing: 16) { + Text("System Information") + .font(.system(.title2, design: .default, weight: .bold)) + .foregroundColor(.primary) + + HStack(spacing: 12) { + SystemInfoCard(label: "Device", value: getMacModel()) + SystemInfoCard(label: "Processor", value: getCPUInfo()) + SystemInfoCard(label: "Memory", value: getMemoryInfo()) + } + } + } + private var transcriptionPerformanceSection: some View { VStack(alignment: .leading, spacing: 16) { Text("Transcription Models") @@ -193,6 +209,30 @@ struct PerformanceAnalysisView: View { } } +// MARK: - Helper Functions for System Info + +private func getMacModel() -> String { + var size = 0 + sysctlbyname("hw.model", nil, &size, nil, 0) + var machine = [CChar](repeating: 0, count: size) + sysctlbyname("hw.model", &machine, &size, nil, 0) + return String(cString: machine) +} + +private func getCPUInfo() -> String { + var size = 0 + sysctlbyname("machdep.cpu.brand_string", nil, &size, nil, 0) + var buffer = [CChar](repeating: 0, count: size) + sysctlbyname("machdep.cpu.brand_string", &buffer, &size, nil, 0) + return String(cString: buffer) +} + +private func getMemoryInfo() -> String { + let totalMemory = ProcessInfo.processInfo.physicalMemory + return ByteCountFormatter.string(fromByteCount: Int64(totalMemory), countStyle: .memory) +} + + // MARK: - Subviews struct SummaryCard: View { @@ -215,6 +255,47 @@ struct SummaryCard: View { } } +struct InfoRow: View { + let label: String + let value: String + + var body: some View { + HStack { + Text(label) + .font(.headline) + .foregroundColor(.secondary) + Spacer() + Text(value) + .font(.body) + .foregroundColor(.primary) + } + } +} + +struct SystemInfoCard: View { + let label: String + let value: String + + var body: some View { + VStack(alignment: .leading, spacing: 4) { + Text(label) + .font(.caption.weight(.medium)) + .foregroundColor(.secondary) + .textCase(.uppercase) + + Text(value) + .font(.system(.body, design: .default, weight: .semibold)) + .foregroundColor(.primary) + .lineLimit(2) + .fixedSize(horizontal: false, vertical: true) + } + .padding(12) + .frame(maxWidth: .infinity, minHeight: 60, alignment: .leading) + .background(CardBackground(isSelected: false)) + .cornerRadius(8) + } +} + struct TranscriptionModelCard: View { let modelStat: PerformanceAnalysisView.ModelStat