Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 0 additions & 74 deletions .codeclimate.yml

This file was deleted.

92 changes: 92 additions & 0 deletions tinyHelper/logHelper_extractProcessAndTimes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

# Script to extract and match "runs as process" lines with their corresponding "cpu time DFA" lines
# Usage: ./extractProcessAndTimes <logfile>

if [ $# -eq 0 ]; then
echo "Usage: $0 <logfile>"
echo "Example: $0 runAna4ProbAna_20250917_14h34m46s.log"
exit 1
fi

logFile="$1"

if [ ! -f "$logFile" ]; then
echo "Error: File '$logFile' not found!"
exit 1
fi

echo "Extracting process and timing information from: $logFile"
echo "================================================================"
echo

# Create temporary files to store the extracted data
processLines=$(mktemp)
timingLines=$(mktemp)

# Extract all "runs as process" lines with line numbers
grep -n "runs as process" "$logFile" > "$processLines"

# Extract all "cpu time DFA" lines with line numbers
grep -n "cpu time DFA" "$logFile" > "$timingLines"

# Function to extract process ID from a line
getProcessId() {
echo "$1" | cut -d',' -f1 | cut -d':' -f2
}

# Function to extract simulation name from process line
getSimName() {
echo "$1" | sed 's/.*INFO - \(.*\) runs as process.*/\1/'
Comment thread
fso42 marked this conversation as resolved.
}

# Function to extract CPU time from timing line
getCpuTime() {
echo "$1" | sed 's/.*cpu time DFA = \([0-9.]*\) s.*/\1/'
Comment thread
fso42 marked this conversation as resolved.
}

# Counter for matched pairs
counter=1

echo "Matched Process and Timing Pairs:"
echo "=================================="

# Read process lines and find matching timing lines
while IFS= read -r processLine; do
processId=$(getProcessId "$processLine")
simName=$(getSimName "$processLine")
processLineNum=$(echo "$processLine" | cut -d':' -f1)

# Find the next timing line with the same process ID that comes after this process line
matchingTiming=$(awk -F: -v pid="$processId" -v startLine="$processLineNum" '
$1 > startLine && $2 ~ "^"pid"," && /cpu time DFA/ {
print $0
exit
}
' "$timingLines")

if [ -n "$matchingTiming" ]; then
cpuTime=$(getCpuTime "$matchingTiming")
printf "%2d. %-30s (PID: %s) → CPU time: %ss\n" "$counter" "$simName" "$processId" "$cpuTime"
((counter++))
fi

done < "$processLines"

echo
echo "Summary:"
echo "========"
echo "Total matched pairs: $((counter-1))"

# Count simulations per process ID
echo "Process distribution:"
for pid in $(cut -d',' -f1 "$processLines" | cut -d':' -f2 | sort -u); do
Comment thread
fso42 marked this conversation as resolved.
count=$(grep -c "^[0-9]*:$pid," "$processLines")
echo " Process $pid: $count simulations"
done

# Clean up temporary files
rm "$processLines" "$timingLines"

echo
echo "Script completed successfully!"
164 changes: 164 additions & 0 deletions tinyHelper/logHelper_extractProcessTimesAndParams.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/bin/bash

# Enhanced script to extract and match simulations with their parameters and timing
# Usage: ./extractProcessTimesAndParams <logfile>

if [ $# -eq 0 ]; then
echo "Usage: $0 <logfile>"
echo "Example: $0 runAna4ProbAna_20250917_14h34m46s.log"
exit 1
fi

logFile="$1"

if [ ! -f "$logFile" ]; then
echo "Error: File '$logFile' not found!"
exit 1
fi

echo "Extracting simulation data with parameters from: $logFile"
echo "=================================================================="
echo

# Create temporary files to store the extracted data
processLines=$(mktemp)
timingLines=$(mktemp)
thicknessLines=$(mktemp)
musamosatLines=$(mktemp)

# Extract all relevant data with line numbers
grep -n "runs as process" "$logFile" > "$processLines"
grep -n "cpu time DFA" "$logFile" > "$timingLines"
grep -n "'relTh0':" "$logFile" > "$thicknessLines"
grep -n "Friction model parameter used: musamosat" "$logFile" > "$musamosatLines"

# Functions to extract values
getProcessId() {
echo "$1" | cut -d',' -f1 | cut -d':' -f2
}

getSimName() {
echo "$1" | sed 's/.*INFO - \(.*\) runs as process.*/\1/'
Comment thread
fso42 marked this conversation as resolved.
}

getCpuTime() {
echo "$1" | sed 's/.*cpu time DFA = \([0-9.]*\) s.*/\1/'
Comment thread
fso42 marked this conversation as resolved.
}

getThickness() {
echo "$1" | sed "s/.*'relTh0': '\([0-9.]*\)'.*/\1/"
Comment thread
fso42 marked this conversation as resolved.
}

getMusamosat() {
echo "$1" | sed 's/.*musamosat with value \([0-9.]*\).*/\1/'
Comment thread
fso42 marked this conversation as resolved.
}

getLineNumber() {
echo "$1" | cut -d':' -f1
}

# Create arrays to store parameter values for each simulation
declare -A thicknessValues
declare -A musamosatValues
declare -A simCounter

# Count simulations per process to track which parameter set belongs to which simulation
while IFS= read -r processLine; do
processId=$(getProcessId "$processLine")
if [[ -z "${simCounter[$processId]}" ]]; then
simCounter[$processId]=0
else
((simCounter[$processId]++))
fi
done < "$processLines"

# Reset counters for actual processing
declare -A currentSim
Comment thread
fso42 marked this conversation as resolved.

# Process thickness values (relTh0) - these appear sequentially before simulations
thicknessIndex=0
while IFS= read -r thicknessLine; do
thickness=$(getThickness "$thicknessLine")
thicknessValues["$thicknessIndex"]="$thickness"
((thicknessIndex++))
done < "$thicknessLines"

# Reset simulation counters for musamosat processing
declare -A currentSimMu
Comment thread
fso42 marked this conversation as resolved.

# Process musamosat values - these appear before each set of simulations
# We need to map them correctly to the simulation order
musamosatIndex=0
while IFS= read -r musamosatLine; do
musamosat=$(getMusamosat "$musamosatLine")
musamosatValues["$musamosatIndex"]="$musamosat"
((musamosatIndex++))
done < "$musamosatLines"

# Counter for matched pairs
counter=1
musamosatSimIndex=0
thicknessSimIndex=0

echo "Matched Simulations with Parameters and Timing:"
echo "=============================================="
printf "%-3s %-30s %-8s %-12s %-12s %-10s\n" "No." "Simulation Name" "PID" "μ_sat" "Thickness" "CPU Time"
printf "%-3s %-30s %-8s %-12s %-12s %-10s\n" "---" "------------------------------" "--------" "------------" "------------" "----------"

# Read process lines and find matching data
while IFS= read -r processLine; do
processId=$(getProcessId "$processLine")
simName=$(getSimName "$processLine")
processLineNum=$(getLineNumber "$processLine")

# Find matching timing line
matchingTiming=$(awk -F: -v pid="$processId" -v startLine="$processLineNum" '
$1 > startLine && $2 ~ "^"pid"," && /cpu time DFA/ {
print $0
exit
}
' "$timingLines")

if [ -n "$matchingTiming" ]; then
cpuTime=$(getCpuTime "$matchingTiming")

# Get thickness for this simulation (sequential mapping)
thickness="${thicknessValues[$thicknessSimIndex]}"

# Get musamosat for this simulation (they cycle through the parameter sets)
musamosat="${musamosatValues[$musamosatSimIndex]}"

printf "%-3d %-30s %-8s %12.3f %12.3f %-10ss\n" "$counter" "$simName" "$processId" "$musamosat" "$thickness" "$cpuTime"

((counter++))
((musamosatSimIndex++))
((thicknessSimIndex++))

# Reset musamosat index if we've used all parameter sets
if [ "$musamosatSimIndex" -ge "$musamosatIndex" ]; then
musamosatSimIndex=0
fi
fi

done < "$processLines"

echo
echo "Summary:"
echo "========"
echo "Total matched simulations: $((counter-1))"
echo "Parameter sets used:"
echo " Thickness values: $thicknessIndex"
echo " μ_sat values: $musamosatIndex"

# Process distribution
echo "Process distribution:"
for pid in $(cut -d',' -f1 "$processLines" | cut -d':' -f2 | sort -u); do
Comment thread
fso42 marked this conversation as resolved.
count=$(grep -c "^[0-9]*:$pid," "$processLines")
echo " Process $pid: $count simulations"
done

# Clean up temporary files
rm "$processLines" "$timingLines" "$thicknessLines" "$musamosatLines"

echo
echo "Script completed successfully!"
Loading