Last active
July 31, 2025 00:41
-
-
Save TIBTHINK/cfba90cee4a34fca3a754f161b8996b7 to your computer and use it in GitHub Desktop.
linux kernal benchmark
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 characters
| #!/bin/bash | |
| set -e | |
| # === SETTINGS === | |
| REPO_URL="https://github.com/torvalds/linux.git" | |
| WORKDIR="$HOME/kernel-benchmark-github" | |
| SRC_DIR="$WORKDIR/linux" | |
| CORES=$(nproc) | |
| # === FUNCTIONS === | |
| install_dependencies() { | |
| echo "π§ Installing build dependencies..." | |
| sudo apt update | |
| sudo apt install -y build-essential libncurses-dev bison flex libssl-dev libelf-dev bc git curl wget | |
| } | |
| clone_or_update_repo() { | |
| mkdir -p "$WORKDIR" | |
| cd "$WORKDIR" | |
| if [ -d "$SRC_DIR/.git" ]; then | |
| echo "π¦ Updating existing Linux kernel repo..." | |
| cd "$SRC_DIR" | |
| git pull --depth=1 origin master | |
| else | |
| echo "π₯ Cloning Linux kernel from GitHub..." | |
| git clone --depth=1 "$REPO_URL" | |
| cd "$SRC_DIR" | |
| fi | |
| } | |
| build_kernel() { | |
| echo "βοΈ Preparing kernel config..." | |
| if [ -f /boot/config-$(uname -r) ]; then | |
| cp /boot/config-$(uname -r) .config | |
| yes "" | make olddefconfig | |
| else | |
| make defconfig | |
| fi | |
| echo "π Starting kernel compilation using $CORES cores..." | |
| START=$(date +%s) | |
| make -j"$CORES" | |
| END=$(date +%s) | |
| DURATION=$((END - START)) | |
| echo "β Kernel compiled in $DURATION seconds." | |
| } | |
| # === MAIN === | |
| echo "π§ Detected $CORES CPU cores." | |
| install_dependencies | |
| clone_or_update_repo | |
| build_kernel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment