From 01a281d73c4324ad9e45d72b98239de8ececb6de Mon Sep 17 00:00:00 2001 From: saymrwulf Date: Tue, 21 Apr 2026 21:18:25 +0200 Subject: [PATCH] Add tmux powermetrics wall with thermal estimate --- CPUwall.sh | 227 +++++++++++++++++++++++++++++++++++++++++++++++++++ GPUwall.sh | 207 ++++++++++++++++++++++++++++++++++++++++++++++ Readme.md | 41 ++++++++++ tmux-wall.sh | 59 +++++++++++++ 4 files changed, 534 insertions(+) create mode 100755 CPUwall.sh create mode 100755 GPUwall.sh create mode 100644 Readme.md create mode 100755 tmux-wall.sh diff --git a/CPUwall.sh b/CPUwall.sh new file mode 100755 index 0000000..0cda5cb --- /dev/null +++ b/CPUwall.sh @@ -0,0 +1,227 @@ +#!/usr/bin/env bash +set -euo pipefail + +sample_ms="${SAMPLE_MS:-5000}" +hold="${HOLD_SEC:-6}" + +if [[ "${EUID}" -ne 0 ]]; then + exec sudo --preserve-env=SAMPLE_MS,HOLD_SEC bash "$0" "$@" +fi + +cleanup() { + printf '\033[0m\033[?25h\n' +} + +trap cleanup INT TERM EXIT +printf '\033[?25l' + +while :; do + out="$( + powermetrics --samplers cpu_power,gpu_power,thermal -i "${sample_ms}" -n 1 | + SAMPLE_MS="${sample_ms}" HOLD_SEC="${hold}" COLUMNS="${COLUMNS:-120}" perl -0ne ' + use strict; + use warnings; + use utf8; + binmode STDOUT, ":utf8"; + + my (@cluster_order, %clusters, %cores, %cluster_power); + my $current = "UNGROUPED"; + my ($cpu_power_mw, $gpu_power_mw, $gpu_af, $gpu_active, $gpu_idle, $thermal_state); + my %gpu_bins; + + sub parse_hist { + my ($hist) = @_; + my @pairs = ($hist // "") =~ /([\d.]+)\s*MHz:\s*([\d.]+)%/g; + my ($max, $weighted) = (0, 0); + for (my $i = 0; $i < @pairs; $i += 2) { + $max = $pairs[$i] if $pairs[$i] > $max; + $weighted += $pairs[$i] * $pairs[$i + 1] / 100; + } + return ($max, $weighted); + } + + sub color_pct { + my ($p) = @_; + return 46 if $p < 25; + return 118 if $p < 50; + return 226 if $p < 75; + return 208 if $p < 90; + return 196; + } + + sub bar { + my ($pct, $w) = @_; + $pct = 0 if !defined $pct || $pct < 0; + $pct = 100 if $pct > 100; + my $n = int($pct * $w / 100 + 0.5); + return ("█" x $n) . ("░" x ($w - $n)); + } + + sub pressure_factor { + my ($state) = @_; + return 1.00 if !defined $state; + return 1.00 if $state =~ /nominal/i; + return 1.08 if $state =~ /fair|moderate/i; + return 1.18 if $state =~ /serious|heavy/i; + return 1.30 if $state =~ /critical|trapping/i; + return 1.05; + } + + sub state_color { + my ($state) = @_; + return 46 if !defined $state || $state =~ /nominal/i; + return 226 if $state =~ /fair|moderate/i; + return 208 if $state =~ /serious|heavy/i; + return 196 if $state =~ /critical|trapping/i; + return 250; + } + + for my $line (split /\n/, $_) { + if ($line =~ /^((?:E-Cluster|P\d+-Cluster|P-Cluster) HW active residency):\s*([\d.]+)%\s*(?:\((.*)\))?/) { + my ($name, $active, $hist) = ($1, $2, $3 // ""); + $current = $name; + push @cluster_order, $name unless exists $clusters{$name}; + my ($max, $weighted) = parse_hist($hist); + my $eff = $max ? $active * $weighted / $max : $active; + (my $short = $name) =~ s/\s+HW active residency$//; + $clusters{$name} = { active => $active, eff => $eff, max => $max, short => $short }; + } + elsif ($line =~ /^(CPU \d+) active residency:\s*([\d.]+)%\s*(?:\((.*)\))?/) { + my ($cpu, $active, $hist) = ($1, $2, $3 // ""); + my ($max, $weighted) = parse_hist($hist); + my $eff = $max ? $active * $weighted / $max : $active; + push @{ $cores{$current} }, { cpu => $cpu, active => $active, eff => $eff, max => $max }; + } + elsif ($line =~ /^((?:E-Cluster|P\d+-Cluster|P-Cluster)) Power:\s*([\d.]+)\s*mW/) { + $cluster_power{$1} = $2 / 1000; + } + elsif ($line =~ /^CPU Power:\s*([\d.]+)\s*mW/) { + $cpu_power_mw = $1; + } + elsif ($line =~ /^GPU HW active frequency:\s*([\d.]+)\s*MHz/) { + $gpu_af = $1; + } + elsif ($line =~ /^GPU(?: HW)? active residency:\s*([\d.]+)%\s*\((.*)\)/) { + $gpu_active = $1; + my @pairs = $2 =~ /([\d.]+)\s*MHz:\s*([\d.]+)%/g; + for (my $i = 0; $i < @pairs; $i += 2) { + $gpu_bins{$pairs[$i]} += $pairs[$i + 1]; + } + } + elsif ($line =~ /^GPU idle residency:\s*([\d.]+)%/) { + $gpu_idle = $1; + } + elsif ($line =~ /^GPU Power:\s*([\d.]+)\s*mW/) { + $gpu_power_mw = $1; + } + elsif ($line =~ /pressure.*:\s*([A-Za-z]+)/i) { + $thermal_state = $1; + } + } + + my $cols = $ENV{COLUMNS} || 120; + my $barw = $cols > 170 ? 44 : $cols > 135 ? 34 : 24; + my $rule = "─" x ($cols > 100 ? 92 : 70); + my $sample_s = (($ENV{SAMPLE_MS} || 5000) / 1000); + my $hold_s = $ENV{HOLD_SEC} || 6; + my $display_bias_w = defined $ENV{DISPLAY_BIAS_W} ? $ENV{DISPLAY_BIAS_W} : 2.5; + my $spread_theta = defined $ENV{THERMAL_SPREAD_C_PER_W} ? $ENV{THERMAL_SPREAD_C_PER_W} : 0.85; + my $clamshell_factor = defined $ENV{CLAMSHELL_FACTOR} ? $ENV{CLAMSHELL_FACTOR} : 1.08; + + print "\e[1;97mCPU WALL\e[0m sample ${sample_s}s hold ${hold_s}s\n"; + print "\e[38;5;240m$rule\e[0m\n\n"; + + for my $cluster (@cluster_order) { + my $c = $clusters{$cluster}; + my $cluster_color = $cluster =~ /^E-/ ? 45 : 213; + my $cc = color_pct($c->{eff}); + + printf "\e[1;38;5;%sm%-28s\e[0m \e[38;5;%sm%s\e[0m %6.2f%% a:%6.2f%%", + $cluster_color, $cluster, $cc, bar($c->{eff}, $barw), $c->{eff}, $c->{active}; + printf " max:%4d MHz", $c->{max} if $c->{max}; + print "\n"; + + for my $r (@{ $cores{$cluster} || [] }) { + my $pc = color_pct($r->{eff}); + printf " %-6s \e[38;5;%sm%s\e[0m %6.2f%% a:%6.2f%%", + $r->{cpu}, $pc, bar($r->{eff}, $barw), $r->{eff}, $r->{active}; + printf " max:%4d MHz", $r->{max} if $r->{max}; + print "\n"; + } + print "\n"; + } + + my ($gpu_max, $cpu_eff_total, $cpu_eff_n) = (0, 0, 0); + for my $cluster (@cluster_order) { + $cpu_eff_total += $clusters{$cluster}{eff}; + $cpu_eff_n++; + } + $cpu_eff_total = $cpu_eff_n ? ($cpu_eff_total / $cpu_eff_n) : 0; + + for my $f (keys %gpu_bins) { + $gpu_max = $f if $f > $gpu_max; + } + + my $gpu_used = ($gpu_max && defined $gpu_af && defined $gpu_active) + ? ($gpu_active * $gpu_af / $gpu_max) + : (defined $gpu_active ? $gpu_active : undef); + + my $cpu_hot_w; + my $cpu_hot_name = "CPU hotspot est"; + for my $cluster (@cluster_order) { + my $short = $clusters{$cluster}{short}; + next unless exists $cluster_power{$short}; + if (!defined $cpu_hot_w || $cluster_power{$short} > $cpu_hot_w) { + $cpu_hot_w = $cluster_power{$short}; + $cpu_hot_name = $short; + } + } + + my $cpu_power_w = defined $cpu_power_mw ? ($cpu_power_mw / 1000) : undef; + if (!defined $cpu_hot_w && defined $cpu_power_w) { + my $hot_frac = $cpu_eff_total >= 85 ? 0.62 + : $cpu_eff_total >= 60 ? 0.52 + : $cpu_eff_total >= 35 ? 0.42 + : 0.32; + $cpu_hot_w = $cpu_power_w * $hot_frac; + } + + my $gpu_power_w = defined $gpu_power_mw ? ($gpu_power_mw / 1000) : undef; + my $display_component_w = defined $gpu_used && $gpu_used >= 20 ? ($display_bias_w * 0.70) : $display_bias_w; + my $gpu_zone_w = defined $gpu_power_w + ? ($gpu_power_w + $display_component_w) + : (defined $gpu_used ? ((0.04 * $gpu_used) + $display_component_w) : undef); + + my $gradient_c = (defined $cpu_hot_w && defined $gpu_zone_w) + ? abs($cpu_hot_w - $gpu_zone_w) * $spread_theta * pressure_factor($thermal_state) * $clamshell_factor + : undef; + my $gradient_side = !defined $gradient_c ? "insufficient data" + : $cpu_hot_w >= $gpu_zone_w ? "CPU side hotter" + : "GPU/display side hotter"; + my $basis = (defined $cpu_power_w && defined $gpu_power_w) ? "power-based estimate" : "util fallback"; + my $state = defined $thermal_state ? $thermal_state : "n/a"; + my $state_color = state_color($thermal_state); + + print "\e[1;97mTHERMAL ESTIMATE\e[0m\n"; + print "\e[38;5;240m$rule\e[0m\n\n"; + printf " pressure \e[38;5;%sm%s\e[0m\n", $state_color, $state; + printf " cpu hotspot %6.2f W %s\n", $cpu_hot_w, $cpu_hot_name if defined $cpu_hot_w; + if (defined $gpu_zone_w) { + if (defined $gpu_power_w) { + printf " gpu zone %6.2f W gpu %.2f + display %.2f\n", $gpu_zone_w, $gpu_power_w, $display_component_w; + } else { + printf " gpu zone %6.2f W util fallback + display %.2f\n", $gpu_zone_w, $display_component_w; + } + } + printf " est gradient %6.2f C %s\n", $gradient_c, $gradient_side if defined $gradient_c; + printf " basis %s\n", $basis; + print " note estimate only, not a sensor temperature\n"; + ' + )" + + printf '\033[2J\033[H' + printf '\033[1;37m%s\033[0m\n\n' "$(date '+%Y-%m-%d %H:%M:%S')" + printf '%s\n' "${out}" + + sleep "${hold}" +done diff --git a/GPUwall.sh b/GPUwall.sh new file mode 100755 index 0000000..46aff69 --- /dev/null +++ b/GPUwall.sh @@ -0,0 +1,207 @@ +#!/usr/bin/env bash +set -euo pipefail + +sample_ms="${SAMPLE_MS:-5000}" +hold="${HOLD_SEC:-6}" + +if [[ "${EUID}" -ne 0 ]]; then + exec sudo --preserve-env=SAMPLE_MS,HOLD_SEC bash "$0" "$@" +fi + +cleanup() { + printf '\033[0m\033[?25h\n' +} + +trap cleanup INT TERM EXIT +printf '\033[?25l' + +while :; do + out="$( + powermetrics --samplers cpu_power,gpu_power,thermal -i "${sample_ms}" -n 1 | + SAMPLE_MS="${sample_ms}" HOLD_SEC="${hold}" COLUMNS="${COLUMNS:-120}" perl -0ne ' + use strict; + use warnings; + use utf8; + binmode STDOUT, ":utf8"; + + my ($af, $active, $idle, $pwr, $cpu_power_mw, $thermal_state); + my %bins; + my (@cluster_order, %clusters, %cluster_power); + + sub pct_color { + my ($p) = @_; + return 46 if $p < 25; + return 118 if $p < 50; + return 226 if $p < 75; + return 208 if $p < 90; + return 196; + } + + sub bar { + my ($pct, $w, $fg) = @_; + $pct = 0 if !defined $pct || $pct < 0; + $pct = 100 if $pct > 100; + my $n = int($pct * $w / 100 + 0.5); + return sprintf("\e[38;5;%sm%s\e[0m%s", $fg, ("█" x $n), ("░" x ($w - $n))); + } + + sub parse_hist { + my ($hist) = @_; + my @pairs = ($hist // "") =~ /([\d.]+)\s*MHz:\s*([\d.]+)%/g; + my ($max, $weighted) = (0, 0); + for (my $i = 0; $i < @pairs; $i += 2) { + $max = $pairs[$i] if $pairs[$i] > $max; + $weighted += $pairs[$i] * $pairs[$i + 1] / 100; + } + return ($max, $weighted); + } + + sub pressure_factor { + my ($state) = @_; + return 1.00 if !defined $state; + return 1.00 if $state =~ /nominal/i; + return 1.08 if $state =~ /fair|moderate/i; + return 1.18 if $state =~ /serious|heavy/i; + return 1.30 if $state =~ /critical|trapping/i; + return 1.05; + } + + sub state_color { + my ($state) = @_; + return 46 if !defined $state || $state =~ /nominal/i; + return 226 if $state =~ /fair|moderate/i; + return 208 if $state =~ /serious|heavy/i; + return 196 if $state =~ /critical|trapping/i; + return 250; + } + + for my $line (split /\n/, $_) { + $af = $1 if $line =~ /^GPU HW active frequency:\s*([\d.]+)\s*MHz/; + + if ($line =~ /^GPU(?: HW)? active residency:\s*([\d.]+)%\s*\((.*)\)/) { + $active = $1; + my @pairs = $2 =~ /([\d.]+)\s*MHz:\s*([\d.]+)%/g; + for (my $i = 0; $i < @pairs; $i += 2) { + $bins{$pairs[$i]} += $pairs[$i + 1]; + } + } + + $idle = $1 if $line =~ /^GPU idle residency:\s*([\d.]+)%/; + $pwr = $1 if $line =~ /^GPU Power:\s*([\d.]+)\s*mW/; + $cpu_power_mw = $1 if $line =~ /^CPU Power:\s*([\d.]+)\s*mW/; + $thermal_state = $1 if $line =~ /pressure.*:\s*([A-Za-z]+)/i; + + if ($line =~ /^((?:E-Cluster|P\d+-Cluster|P-Cluster) HW active residency):\s*([\d.]+)%\s*(?:\((.*)\))?/) { + my ($name, $active_res, $hist) = ($1, $2, $3 // ""); + push @cluster_order, $name unless exists $clusters{$name}; + my ($max_res, $weighted_res) = parse_hist($hist); + my $eff = $max_res ? $active_res * $weighted_res / $max_res : $active_res; + (my $short = $name) =~ s/\s+HW active residency$//; + $clusters{$name} = { eff => $eff, short => $short }; + } + elsif ($line =~ /^((?:E-Cluster|P\d+-Cluster|P-Cluster)) Power:\s*([\d.]+)\s*mW/) { + $cluster_power{$1} = $2 / 1000; + } + } + + my $max = 0; + for my $f (keys %bins) { + $max = $f if $f > $max; + } + + my $used = ($max && defined $af && defined $active) ? ($active * $af / $max) : ($active // 0); + my $freq_pct = ($max && defined $af) ? (100 * $af / $max) : 0; + + my $cols = $ENV{COLUMNS} || 120; + my $bigw = $cols > 170 ? 54 : $cols > 135 ? 42 : 30; + my $smallw = $cols > 170 ? 36 : $cols > 135 ? 28 : 20; + my $rule = "─" x ($cols > 100 ? 92 : 70); + my $sample_s = (($ENV{SAMPLE_MS} || 5000) / 1000); + my $hold_s = $ENV{HOLD_SEC} || 6; + my $display_bias_w = defined $ENV{DISPLAY_BIAS_W} ? $ENV{DISPLAY_BIAS_W} : 2.5; + my $spread_theta = defined $ENV{THERMAL_SPREAD_C_PER_W} ? $ENV{THERMAL_SPREAD_C_PER_W} : 0.85; + my $clamshell_factor = defined $ENV{CLAMSHELL_FACTOR} ? $ENV{CLAMSHELL_FACTOR} : 1.08; + + print "\e[1;97mGPU WALL\e[0m sample ${sample_s}s hold ${hold_s}s\n"; + print "\e[38;5;240m$rule\e[0m\n\n"; + + printf " used_of_max %6.2f%% %s\n", $used, bar($used, $bigw, pct_color($used)); + printf " active %6.2f%% %s\n", $active, bar($active, $bigw, pct_color($active)); + printf " freq_of_max %6.2f%% %s\n", $freq_pct, bar($freq_pct, $bigw, 39); + printf " idle %6.2f%% %s\n\n", $idle, bar($idle, $bigw, 244); + + printf " active freq %6.0f MHz\n", $af if defined $af; + printf " top bin %6.0f MHz\n", $max if $max; + printf " power est %6.2f W\n", ($pwr / 1000) if defined $pwr; + + print "\n\e[1;97m frequency mix\e[0m\n\n"; + + for my $f (sort { $a <=> $b } keys %bins) { + next if $bins{$f} <= 0; + printf " %4d MHz %6.2f%% %s\n", + $f, $bins{$f}, bar($bins{$f}, $smallw, 45); + } + + my ($cpu_hot_w, $cpu_hot_name) = (undef, "CPU hotspot est"); + my ($cpu_eff_total, $cpu_eff_n) = (0, 0); + for my $cluster (@cluster_order) { + $cpu_eff_total += $clusters{$cluster}{eff}; + $cpu_eff_n++; + + my $short = $clusters{$cluster}{short}; + next unless exists $cluster_power{$short}; + if (!defined $cpu_hot_w || $cluster_power{$short} > $cpu_hot_w) { + $cpu_hot_w = $cluster_power{$short}; + $cpu_hot_name = $short; + } + } + $cpu_eff_total = $cpu_eff_n ? ($cpu_eff_total / $cpu_eff_n) : 0; + + my $cpu_power_w = defined $cpu_power_mw ? ($cpu_power_mw / 1000) : undef; + if (!defined $cpu_hot_w && defined $cpu_power_w) { + my $hot_frac = $cpu_eff_total >= 85 ? 0.62 + : $cpu_eff_total >= 60 ? 0.52 + : $cpu_eff_total >= 35 ? 0.42 + : 0.32; + $cpu_hot_w = $cpu_power_w * $hot_frac; + } + + my $gpu_power_w = defined $pwr ? ($pwr / 1000) : undef; + my $display_component_w = defined $used && $used >= 20 ? ($display_bias_w * 0.70) : $display_bias_w; + my $gpu_zone_w = defined $gpu_power_w + ? ($gpu_power_w + $display_component_w) + : (defined $used ? ((0.04 * $used) + $display_component_w) : undef); + + my $gradient_c = (defined $cpu_hot_w && defined $gpu_zone_w) + ? abs($cpu_hot_w - $gpu_zone_w) * $spread_theta * pressure_factor($thermal_state) * $clamshell_factor + : undef; + my $gradient_side = !defined $gradient_c ? "insufficient data" + : $cpu_hot_w >= $gpu_zone_w ? "CPU side hotter" + : "GPU/display side hotter"; + my $basis = (defined $cpu_power_w && defined $gpu_power_w) ? "power-based estimate" : "util fallback"; + my $state = defined $thermal_state ? $thermal_state : "n/a"; + my $state_color = state_color($thermal_state); + + print "\n\e[1;97mTHERMAL ESTIMATE\e[0m\n"; + print "\e[38;5;240m$rule\e[0m\n\n"; + printf " pressure \e[38;5;%sm%s\e[0m\n", $state_color, $state; + printf " cpu hotspot %6.2f W %s\n", $cpu_hot_w, $cpu_hot_name if defined $cpu_hot_w; + if (defined $gpu_zone_w) { + if (defined $gpu_power_w) { + printf " gpu zone %6.2f W gpu %.2f + display %.2f\n", $gpu_zone_w, $gpu_power_w, $display_component_w; + } else { + printf " gpu zone %6.2f W util fallback + display %.2f\n", $gpu_zone_w, $display_component_w; + } + } + printf " est gradient %6.2f C %s\n", $gradient_c, $gradient_side if defined $gradient_c; + printf " basis %s\n", $basis; + print " note estimate only, not a sensor temperature\n"; + ' + )" + + printf '\033[2J\033[H' + printf '\033[1;37m%s\033[0m\n\n' "$(date '+%Y-%m-%d %H:%M:%S')" + printf '%s\n' "${out}" + + sleep "${hold}" +done diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..3be22c1 --- /dev/null +++ b/Readme.md @@ -0,0 +1,41 @@ +# powermetrics inside tmux + +Make the scripts executable once: + +```bash +chmod +x CPUwall.sh GPUwall.sh tmux-wall.sh +``` + +Start the split view with one command: + +```bash +./tmux-wall.sh +``` + +It will ask for your password once at startup, then create and attach to a root-owned tmux session. + +Recreate the tmux session after script changes: + +```bash +TMUX_RECREATE=1 ./tmux-wall.sh +``` + +Useful overrides: + +```bash +SAMPLE_MS=2000 HOLD_SEC=2 ./tmux-wall.sh +``` + +Thermal estimate tuning: + +```bash +DISPLAY_BIAS_W=2.5 THERMAL_SPREAD_C_PER_W=0.85 CLAMSHELL_FACTOR=1.08 ./tmux-wall.sh +``` + +The thermal section is an estimate derived from `powermetrics` CPU/GPU power and activity plus thermal pressure. It is not a direct temperature sensor reading. + +If you want to attach to an existing session later: + +```bash +sudo tmux attach -t powermetrics +``` diff --git a/tmux-wall.sh b/tmux-wall.sh new file mode 100755 index 0000000..3135309 --- /dev/null +++ b/tmux-wall.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +set -euo pipefail + +session_name="${TMUX_SESSION_NAME:-powermetrics}" +window_name="${TMUX_WINDOW_NAME:-wall}" +recreate_session="${TMUX_RECREATE:-0}" +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +sample_ms="${SAMPLE_MS:-5000}" +hold_sec="${HOLD_SEC:-6}" +display_bias_w="${DISPLAY_BIAS_W:-}" +thermal_spread="${THERMAL_SPREAD_C_PER_W:-}" +clamshell_factor="${CLAMSHELL_FACTOR:-}" + +if [[ "${EUID}" -ne 0 ]]; then + exec sudo --preserve-env=TMUX_SESSION_NAME,TMUX_WINDOW_NAME,TMUX_RECREATE,SAMPLE_MS,HOLD_SEC,DISPLAY_BIAS_W,THERMAL_SPREAD_C_PER_W,CLAMSHELL_FACTOR bash "$0" "$@" +fi + +if ! command -v tmux >/dev/null 2>&1; then + echo "tmux is not installed." >&2 + exit 1 +fi + +if ! command -v powermetrics >/dev/null 2>&1; then + echo "powermetrics is not available on this system." >&2 + exit 1 +fi + +if [[ ! -x "${script_dir}/CPUwall.sh" || ! -x "${script_dir}/GPUwall.sh" ]]; then + echo "CPUwall.sh and GPUwall.sh must be executable. Run: chmod +x CPUwall.sh GPUwall.sh tmux-wall.sh" >&2 + exit 1 +fi + +env_prefix="SAMPLE_MS=${sample_ms} HOLD_SEC=${hold_sec}" +if [[ -n "${display_bias_w}" ]]; then + env_prefix="${env_prefix} DISPLAY_BIAS_W=${display_bias_w}" +fi +if [[ -n "${thermal_spread}" ]]; then + env_prefix="${env_prefix} THERMAL_SPREAD_C_PER_W=${thermal_spread}" +fi +if [[ -n "${clamshell_factor}" ]]; then + env_prefix="${env_prefix} CLAMSHELL_FACTOR=${clamshell_factor}" +fi + +if tmux has-session -t "${session_name}" 2>/dev/null; then + if [[ "${recreate_session}" == "1" ]]; then + tmux kill-session -t "${session_name}" + else + exec tmux attach -t "${session_name}" + fi +fi + +tmux new-session -d -s "${session_name}" -n "${window_name}" -c "${script_dir}" +tmux send-keys -t "${session_name}:${window_name}.0" "${env_prefix} ./CPUwall.sh" C-m +tmux split-window -h -t "${session_name}:${window_name}" -c "${script_dir}" +tmux send-keys -t "${session_name}:${window_name}.1" "${env_prefix} ./GPUwall.sh" C-m +tmux select-layout -t "${session_name}:${window_name}" even-horizontal + +exec tmux attach -t "${session_name}"