Last active
December 22, 2023 09:43
-
-
Save roworu/e8876e567244ea06417aa8784bcc0a49 to your computer and use it in GitHub Desktop.
Revisions
-
roworu revised this gist
Dec 22, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ collect_results() { echo "CPU Name: $cpu_name" >> "$results_file" echo "Memory: $memory" >> "$results_file" echo "Number of Cores: $cores" >> "$results_file" echo "---------------------------------" >> "$results_file" echo "" >> "$results_file" # Append iteration times and average times to the results file @@ -31,7 +31,7 @@ collect_results() { echo "Build Time: ${build_times[$i]} seconds" >> "$results_file" echo "" >> "$results_file" done echo "---------------------------------" >> "$results_file" echo "Average Times:" >> "$results_file" echo "Average Extraction Time: ${average_extract_time} seconds" >> "$results_file" echo "Average Build Time: ${average_build_time} seconds" >> "$results_file" -
roworu revised this gist
Dec 22, 2023 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -69,25 +69,19 @@ for ((i=0; i<num_iterations; i++)) do # Start time after downloading extract_start_time=$(date +%s) tar -xvf ${current_dir}/linux-5.15.144.tar.xz &> /dev/null extract_end_time=$(date +%s) extract_duration=$((extract_end_time - extract_start_time)) cd ${current_dir}/linux-5.15.144 make defconfig &> /dev/null # Measure time to compile (excluding download and extraction times) compile_start_time=$(date +%s) make -j"$(nproc)" &> /dev/null compile_end_time=$(date +%s) compile_duration=$((compile_end_time - compile_start_time)) # Delete build folder after each iteration rm -rf ${current_dir}/linux-5.15.144 cd $current_dir # Record times for download, extraction, and build @@ -108,7 +102,6 @@ do average_build_time=$((total_build_time / (i+1))) done collect_results echo "Results saved to: $results_file" -
roworu revised this gist
Dec 22, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,7 @@ collect_results() { echo "CPU Name: $cpu_name" >> "$results_file" echo "Memory: $memory" >> "$results_file" echo "Number of Cores: $cores" >> "$results_file" echo "---------------------------------" echo "" >> "$results_file" # Append iteration times and average times to the results file @@ -30,7 +31,7 @@ collect_results() { echo "Build Time: ${build_times[$i]} seconds" >> "$results_file" echo "" >> "$results_file" done echo "---------------------------------" echo "Average Times:" >> "$results_file" echo "Average Extraction Time: ${average_extract_time} seconds" >> "$results_file" echo "Average Build Time: ${average_build_time} seconds" >> "$results_file" @@ -67,7 +68,6 @@ fi for ((i=0; i<num_iterations; i++)) do # Start time after downloading extract_start_time=$(date +%s) echo "Extracting file: ${current_dir}/linux-5.15.144.tar.xz" tar -xvf ${current_dir}/linux-5.15.144.tar.xz &> /dev/null -
roworu revised this gist
Dec 22, 2023 . 1 changed file with 11 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,6 +60,7 @@ done # Download the kernel (if not downloaded already) if [ ! -f "${current_dir}/linux-5.15.144.tar.xz" ]; then echo "Downloading ..." wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.144.tar.xz -O ${current_dir}/linux-5.15.144.tar.xz fi @@ -68,22 +69,28 @@ do # Start time after downloading start_time=$(date +%s) extract_start_time=$(date +%s) echo "Extracting file: ${current_dir}/linux-5.15.144.tar.xz" tar -xvf ${current_dir}/linux-5.15.144.tar.xz &> /dev/null extract_end_time=$(date +%s) extract_duration=$((extract_end_time - extract_start_time)) echo "cd to ${current_dir}/linux-5.15.144" cd ${current_dir}/linux-5.15.144 echo "defconfig..." make defconfig &> /dev/null # Measure time to compile (excluding download and extraction times) compile_start_time=$(date +%s) echo "compiling..." make -j"$(nproc)" &> /dev/null compile_end_time=$(date +%s) compile_duration=$((compile_end_time - compile_start_time)) # Delete build folder after each iteration echo "Deleting: ${current_dir}/linux-5.15.144" rm -rf ${current_dir}/linux-5.15.144 echo "cd to ${current_dir}" cd $current_dir # Record times for download, extraction, and build extract_times[$i]=$extract_duration build_times[$i]=$compile_duration @@ -101,7 +108,7 @@ do average_build_time=$((total_build_time / (i+1))) done echo "collecting results..." collect_results echo "Results saved to: $results_file" -
roworu revised this gist
Dec 22, 2023 . 1 changed file with 8 additions and 28 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,20 +5,6 @@ current_dir=$(pwd "$0") timestamp=$(date +%Y-%m-%d_%H-%M-%S) results_file="${current_dir}/results_${timestamp}.txt" collect_results() { # Get system information kernel_version=$(uname -r) @@ -73,28 +59,24 @@ while getopts ":n:" opt; do done # Download the kernel (if not downloaded already) if [ ! -f "${current_dir}/linux-5.15.144.tar.xz" ]; then wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.144.tar.xz -O ${current_dir}/linux-5.15.144.tar.xz fi for ((i=0; i<num_iterations; i++)) do # Start time after downloading start_time=$(date +%s) extract_start_time=$(date +%s) tar -xvf ${current_dir}/linux-5.15.144.tar.xz &> /dev/null extract_end_time=$(date +%s) extract_duration=$((extract_end_time - extract_start_time)) cd ${current_dir}/linux-5.15.144 make defconfig &> /dev/null # Measure time to compile (excluding download and extraction times) compile_start_time=$(date +%s) make -j"$(nproc)" &> /dev/null compile_end_time=$(date +%s) compile_duration=$((compile_end_time - compile_start_time)) @@ -115,14 +97,12 @@ do total_build_time=$((total_build_time + build_times[$j])) done average_extract_time=$((total_extract_time / (i+1))) average_build_time=$((total_build_time / (i+1))) done collect_results echo "Results saved to: $results_file" -
roworu revised this gist
Dec 22, 2023 . 1 changed file with 44 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,23 @@ #!/bin/bash # Create the results file with current date current_dir=$(pwd "$0") timestamp=$(date +%Y-%m-%d_%H-%M-%S) results_file="${current_dir}/results_${timestamp}.txt" function loading_animation() { local pid=$! local delay=0.1 local spinstr='|/-\' while ps -p $pid >/dev/null; do local temp=${spinstr#?} printf " [%c] " "$spinstr" local spinstr=$temp${spinstr%"$temp"} sleep $delay printf "\b\b\b\b\b\b" done printf " \b\b\b\b" } collect_results() { # Get system information @@ -8,9 +26,7 @@ collect_results() { memory=$(free -h | awk 'NR==2{print $2}') cores=$(nproc) echo "System Information:" > "$results_file" echo "Kernel Version: $kernel_version" >> "$results_file" @@ -32,6 +48,7 @@ collect_results() { echo "Average Times:" >> "$results_file" echo "Average Extraction Time: ${average_extract_time} seconds" >> "$results_file" echo "Average Build Time: ${average_build_time} seconds" >> "$results_file" } # Number of iterations for compiling the kernel @@ -41,10 +58,12 @@ declare -a build_times num_iterations=3 # Parse command-line options while getopts ":n:" opt; do case $opt in n) num_iterations=$OPTARG echo "Using num_iterations = $OPTARG" ;; \?) echo "Invalid option: -$OPTARG. Usage: $0 -n <num_iterations>" >&2 @@ -53,38 +72,40 @@ while getopts ":n:" opt; do esac done # Download the kernel (if not downloaded already) if [ ! -f "linux-5.15.144.tar.xz" ]; then wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.144.tar.xz fi for ((i=0; i<num_iterations; i++)) do # Start time after downloading start_time=$(date +%s) extract_start_time=$(date +%s) tar -xvf linux-5.15.144.tar.xz &> /dev/null & loading_animation wait $! extract_end_time=$(date +%s) extract_duration=$((extract_end_time - extract_start_time)) cd ${current_dir}/linux-5.15.144 make defconfig &> /dev/null & loading_animation wait $! # Measure time to compile (excluding download and extraction times) compile_start_time=$(date +%s) make -j"$(nproc)" &> /dev/null & loading_animation wait $! compile_end_time=$(date +%s) compile_duration=$((compile_end_time - compile_start_time)) # Delete build folder after each iteration rm -rf ${current_dir}/linux-5.15.144 # Record times for download, extraction, and build extract_times[$i]=$extract_duration build_times[$i]=$compile_duration # Calculate average times total_extract_time=0 total_build_time=0 @@ -94,9 +115,14 @@ do total_build_time=$((total_build_time + build_times[$j])) done average_extract_time=$((total_extract_time / (i+1))) average_build_time=$((total_build_time / (i+1))) done collect_results rm -rf ${current_dir}/linux* echo "Results saved to: $results_file" -
roworu revised this gist
Dec 22, 2023 . 1 changed file with 67 additions and 78 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,113 +1,102 @@ #!/bin/bash collect_results() { # Get system information kernel_version=$(uname -r) cpu_name=$(cat /proc/cpuinfo | grep "model name" | uniq | cut -d ":" -f 2 | sed 's/^[ \t]*//') memory=$(free -h | awk 'NR==2{print $2}') cores=$(nproc) # Create the results file with current date timestamp=$(date +%Y-%m-%d_%H-%M-%S) results_file="results_${timestamp}.txt" echo "System Information:" > "$results_file" echo "Kernel Version: $kernel_version" >> "$results_file" echo "CPU Name: $cpu_name" >> "$results_file" echo "Memory: $memory" >> "$results_file" echo "Number of Cores: $cores" >> "$results_file" echo "" >> "$results_file" # Append iteration times and average times to the results file echo "Iteration Times:" >> "$results_file" for ((i=0; i<num_iterations; i++)) do echo "Iteration $((i+1)):" >> "$results_file" echo "Extraction Time: ${extract_times[$i]} seconds" >> "$results_file" echo "Build Time: ${build_times[$i]} seconds" >> "$results_file" echo "" >> "$results_file" done echo "Average Times:" >> "$results_file" echo "Average Extraction Time: ${average_extract_time} seconds" >> "$results_file" echo "Average Build Time: ${average_build_time} seconds" >> "$results_file" } # Number of iterations for compiling the kernel declare -a extract_times declare -a build_times num_iterations=3 # Parse command-line options while getopts ":n:" opt; do case $opt in n) num_iterations=$OPTARG ;; \?) echo "Invalid option: -$OPTARG. Usage: $0 -n <num_iterations>" >&2 exit 1 ;; esac done # Download the kernel (if not downloaded already) if [ ! -f "linux-5.15.144.tar.xz" ]; then wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.144.tar.xz fi for ((i=0; i<num_iterations; i++)) do # Start time after downloading start_time=$(date +%s) extract_start_time=$(date +%s) tar -xvf linux-5.15.144.tar.xz extract_end_time=$(date +%s) extract_duration=$((extract_end_time - extract_start_time)) cd linux-5.15.144 make defconfig # Measure time to compile (excluding download and extraction times) compile_start_time=$(date +%s) make -j"$(nproc)" compile_end_time=$(date +%s) compile_duration=$((compile_end_time - compile_start_time)) # Delete build folder after each iteration rm -rf linux-5.15.144 # Record times for download, extraction, and build extract_times[$i]=$extract_duration build_times[$i]=$compile_duration # Calculate average times total_extract_time=0 total_build_time=0 for ((j=0; j<=i; j++)) do total_extract_time=$((total_extract_time + extract_times[$j])) total_build_time=$((total_build_time + build_times[$j])) done average_extract_time=$((total_extract_time / (i+1))) average_build_time=$((total_build_time / (i+1))) done # Collect results and write to file collect_results -
roworu created this gist
Dec 22, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,113 @@ #!/bin/bash # Function to check if required packages are installed regardless of package manager check_packages() { required_packages=() missing_packages=() if command -v dpkg &> /dev/null; then # Debian-based systems required_packages=("git" "fakeroot" "build-essential" "ncurses-dev" "xz-utils" "libssl-dev" "bc" "flex" "libelf-dev" "bison") elif command -v dnf &> /dev/null; then # Fedora-based systems required_packages=("gcc" "flex" "make" "bison" "openssl-devel" "elfutils-libelf-devel") else echo "Unable to determine the package manager. Please make sure the required packages are installed manually." exit 1 fi for package in "${required_packages[@]}" do if ! command -v dpkg &> /dev/null && ! command -v dnf &> /dev/null; then echo "Package manager not found. Please install the required packages manually." exit 1 fi if command -v dpkg &> /dev/null && ! dpkg -s "$package" &> /dev/null; then missing_packages+=("$package") elif command -v dnf &> /dev/null && ! dnf list installed "$package" &> /dev/null; then missing_packages+=("$package") fi done if [ ${#missing_packages[@]} -eq 0 ]; then echo "All required packages are installed." else echo "The following packages are missing: ${missing_packages[*]}" echo "Please install them before running the script." exit 1 fi } # Check if required packages are installed regardless of package manager check_packages # Number of iterations for compiling the kernel num_iterations=3 # Array to store individual iteration times declare -a compile_times declare -a extract_times for ((i=0; i<num_iterations; i++)) do # Start time before downloading start_time=$(date +%s) # Download Linux kernel version 5.15.144 if not already downloaded if [ ! -f linux-5.15.144.tar.xz ]; then wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.144.tar.xz fi # Measure time to download (if needed) download_end_time=$(date +%s) download_duration=$((download_end_time - start_time)) echo "Iteration $((i+1)) download took ${download_duration} seconds." # Extract the downloaded kernel and measure time extract_start_time=$(date +%s) tar -xvf linux-5.15.144.tar.xz extract_end_time=$(date +%s) extract_duration=$((extract_end_time - extract_start_time)) echo "Iteration $((i+1)) extraction took ${extract_duration} seconds." # Enter the extracted directory cd linux-5.15.144 # Use the default configuration make defconfig # Measure time to compile (excluding download and extraction times) compile_start_time=$(date +%s) make -j"$(nproc)" compile_end_time=$(date +%s) compile_duration=$((compile_end_time - compile_start_time)) echo "Iteration $((i+1)) compilation took ${compile_duration} seconds." # Store the compile duration and extract duration in the arrays compile_times[$i]=$compile_duration extract_times[$i]=$extract_duration # End time after compilation end_time=$(date +%s) total_duration=$((end_time - start_time)) echo "Iteration $((i+1)) total execution time (including download and extraction): ${total_duration} seconds." # Delete the extracted directory before the next iteration cd .. rm -rf linux-5.15.144 done # Calculate average compile time total_compile_time=0 total_extract_time=0 for ((i=0; i<num_iterations; i++)) do total_compile_time=$((total_compile_time + compile_times[$i])) total_extract_time=$((total_extract_time + extract_times[$i])) done average_compile_time=$((total_compile_time / num_iterations)) average_extract_time=$((total_extract_time / num_iterations)) echo "Average kernel compilation time over $num_iterations iterations: ${average_compile_time} seconds." echo "Average kernel extraction time over $num_iterations iterations: ${average_extract_time} seconds."