Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
972a07c333 | |||
18c63eed72 | |||
50f2a7d65b | |||
6d60f24575 | |||
a5f8d47424 | |||
c26c062182 | |||
3f2fd5fe8a |
15
README.md
15
README.md
@ -1,19 +1,18 @@
|
||||
buildbot-benchmark.bash
|
||||
=======================
|
||||
|
||||
Standardised benchmark for AOSC Buildbots. This benchmark tests the relative
|
||||
performance by building LLVM's core runtime using Ninja.
|
||||
AOSC构建机器标准性能测试套件。本基准测试通过使用Ninja构建LLVM核心运行时来评估相对性能。
|
||||
|
||||
Usage
|
||||
使用方法
|
||||
-----
|
||||
|
||||
Run the benchmark by executing the script:
|
||||
执行以下命令运行测试:
|
||||
|
||||
```
|
||||
bash ./buildbot-benchmark.bash
|
||||
bash -c "$(curl -fsSL https://git.whlug.cn/xunmi/bb/raw/buildbot-benchmark.bash)"
|
||||
```
|
||||
|
||||
Collect "Real" time output from `time` output:
|
||||
从`time`命令输出中提取"Real"实际耗时:
|
||||
|
||||
```
|
||||
real 7m30.250s 7023.34%
|
||||
@ -21,10 +20,10 @@ user 484m4.777s
|
||||
sys 42m40.285s
|
||||
```
|
||||
|
||||
Calculate seconds, rounding up decimals:
|
||||
将时间转换为秒数(向上取整):
|
||||
|
||||
```
|
||||
echo $((7*60 + 31))s
|
||||
```
|
||||
|
||||
Input benchmark results under the "Speed" column in the [Buildbots](https://wiki.aosc.io/developer/infrastructure/buildbots/) page.
|
||||
请将测试结果填写至[构建机器](https://wiki.aosc.io/developer/infrastructure/buildbots/)页面的"性能"一栏。
|
||||
|
@ -1,14 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Basic definitions.
|
||||
BENCHVER=20240318
|
||||
LLVMVER=18.1.1
|
||||
LLVMURL="https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVMVER/llvm-project-$LLVMVER.src.tar.xz"
|
||||
# 基础定义
|
||||
BENCHVER=20240318 # 基准测试版本号
|
||||
LLVMVER=18.1.1 # LLVM版本号
|
||||
LLVMURL="https://git.whlug.cn/api/packages/github-mirror/generic/llvm/$LLVMVER/llvm-project-$LLVMVER.src.tar.xz"
|
||||
LLVMDIR="$(basename $LLVMURL | rev | cut -f3- -d'.' | rev)"
|
||||
DEPENDENCIES="devel-base"
|
||||
DEPENDENCIES="devel-base" # 所需依赖包
|
||||
BUILDLOGFILE="$(pwd)/benchmark.log" # 构建日志文件
|
||||
|
||||
# LLVM configuration options.
|
||||
# LLVM配置选项
|
||||
CONFIG_OPTS=(
|
||||
'-DCMAKE_BUILD_TYPE:STRING=Release'
|
||||
'-DBENCHMARK_BUILD_32_BITS:BOOL=OFF'
|
||||
@ -144,12 +145,12 @@ CONFIG_OPTS=(
|
||||
'-DLLVM_ENABLE_LTO:BOOL=ON'
|
||||
)
|
||||
|
||||
# Autobuild output formatter functions.
|
||||
abwarn() { echo -e "[\e[33mWARN\e[0m]: \e[1m$*\e[0m"; }
|
||||
aberr() { echo -e "[\e[31mERROR\e[0m]: \e[1m$*\e[0m"; exit 1; }
|
||||
abinfo() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; }
|
||||
# 自动构建输出格式化函数
|
||||
abwarn() { echo -e "[\e[33m警告\e[0m]: \e[1m$*\e[0m"; } # 黄色警告信息
|
||||
aberr() { echo -e "[\e[31m错误\e[0m]: \e[1m$*\e[0m"; exit 1; } # 红色错误信息
|
||||
abinfo() { echo -e "[\e[96m信息\e[0m]: \e[1m$*\e[0m"; } # 青色信息提示
|
||||
|
||||
# Autobuild dpkg handler functions.
|
||||
# 软件包管理函数
|
||||
pm_exists(){
|
||||
for p in "$@"; do
|
||||
dpkg $PM_ROOTPARAM -l "$p" | grep ^ii >/dev/null 2>&1 || return 1
|
||||
@ -162,7 +163,7 @@ pm_repoinstall(){
|
||||
apt-get install "$@" --yes
|
||||
}
|
||||
|
||||
# System detection logic.
|
||||
# 系统检测逻辑
|
||||
sys_detect() {
|
||||
. /etc/os-release
|
||||
export $ID
|
||||
@ -170,60 +171,60 @@ sys_detect() {
|
||||
|
||||
echo -e "
|
||||
******************************************************************************
|
||||
---------------- BUILDBOT BENCHMARK (version $BENCHVER) -----------------
|
||||
---------------- 构建机器性能测试套件 (版本 $BENCHVER) -----------------
|
||||
******************************************************************************
|
||||
|
||||
Benchmark: Building LLVM runtime (version $LLVMVER), using Ninja, LTO enabled.
|
||||
测试项目: 构建LLVM运行时 (版本 $LLVMVER), 使用Ninja构建工具, 启用LTO优化
|
||||
|
||||
System architecture: $(uname -m)
|
||||
System processors: $(nproc)
|
||||
System memory: $(( $(cat /proc/meminfo | grep MemTotal | awk '{ print $2 }') / 1024 / 1024 )) GiB
|
||||
系统架构: $(uname -m)
|
||||
处理器核心数: $(nproc)
|
||||
系统内存: $(( $(cat /proc/meminfo | grep MemTotal | awk '{ print $2 }') / 1024 / 1024 )) GiB
|
||||
"
|
||||
|
||||
abinfo "(1/6) Preparing to benchmark Buildbot: Fetching dependencies ..."
|
||||
abinfo "(1/6) 准备基准测试: 获取依赖项..."
|
||||
sys_detect
|
||||
if [[ "$ID" = "aosc" ]]; then
|
||||
if ! pm_exists $DEPENDENCIES; then
|
||||
abinfo "Build or runtime dependencies not satisfied, now fetching needed packages."
|
||||
abinfo "构建或运行时依赖未满足,正在获取所需软件包"
|
||||
pm_repoupdate || \
|
||||
aberr "Failed to refresh repository: $?"
|
||||
aberr "仓库更新失败: $?"
|
||||
pm_repoinstall $DEPENDENCIES || \
|
||||
aberr "Failed to install needed dependencies: $?"
|
||||
aberr "依赖安装失败: $?"
|
||||
fi
|
||||
else
|
||||
abwarn "Non-AOSC OS host detected, you are on your own!
|
||||
abwarn "检测到非AOSC操作系统, 请自行处理依赖项!
|
||||
|
||||
Usually, you would want to install a meta package for basic development
|
||||
tools, such as build-essential for Debian/Ubuntu, or base-devel for
|
||||
Arch Linux.\n"
|
||||
通常您需要安装基础开发工具元包,
|
||||
例如Debian/Ubuntu的ninja和build-essential,
|
||||
或Arch Linux的base-devel。\n"
|
||||
fi
|
||||
|
||||
abinfo "(2/6) Preparing to benchmark Buildbot: Downloading LLVM (version $LLVMVER) ..."
|
||||
wget -c $LLVMURL 2> benchmark.log || \
|
||||
aberr "Failed to download LLVM: $?."
|
||||
abinfo "(2/6) 准备基准测试: 下载LLVM (版本 $LLVMVER)..."
|
||||
wget -c $LLVMURL 2> $BUILDLOGFILE || \
|
||||
aberr "LLVM下载失败: $?."
|
||||
|
||||
abinfo "(3/6) Preparing to benchmark Buildbot: Unpacking LLVM (version $LLVMVER) ..."
|
||||
abinfo "(3/6) 准备基准测试: 解压LLVM (版本 $LLVMVER)..."
|
||||
rm -rf "$LLVMDIR"
|
||||
tar xf $(basename $LLVMURL) || \
|
||||
aberr "Failed to unpack LLVM: $?."
|
||||
aberr "LLVM解压失败: $?."
|
||||
|
||||
abinfo "(4/6) Preparing to benchmark Buildbot: Setting up build environment ..."
|
||||
abinfo "(4/6) 准备基准测试: 设置构建环境..."
|
||||
mkdir -p "$LLVMDIR"/llvm/build || \
|
||||
aberr "Failed to create build directory: $?."
|
||||
aberr "创建构建目录失败: $?."
|
||||
cd "$LLVMDIR"/llvm/build || \
|
||||
aberr "Failed to swtich to build directory: $?."
|
||||
# Set LANG to C to make gcc faster (a little bit)
|
||||
aberr "切换至构建目录失败: $?."
|
||||
# 设置LANG为C以提升gcc编译速度(轻微提升)
|
||||
export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
abinfo "(5/6) Preparing to benchmark Buildbot: Configuring LLVM (version $LLVMVER) ..."
|
||||
abinfo "(5/6) 准备基准测试: 配置LLVM (版本 $LLVMVER)..."
|
||||
cmake .. \
|
||||
"${CONFIG_OPTS[@]}" \
|
||||
-GNinja >> benchmark.log 2>&1 || \
|
||||
aberr "Failed to configure LLVM: $?."
|
||||
-GNinja >> $BUILDLOGFILE 2>&1 || \
|
||||
aberr "LLVM配置失败: $?."
|
||||
|
||||
abinfo "(6/6) Benchmarking Buildbot: Building LLVM ..."
|
||||
time ninja 2>> benchmark.log || \
|
||||
aberr "Failed to build LLVM: $?."
|
||||
abinfo "(6/6) 执行基准测试: 构建LLVM..."
|
||||
time ninja 2>> $BUILDLOGFILE || \
|
||||
aberr "LLVM构建失败: $?."
|
||||
|
||||
unset LC_ALL LANG
|
||||
unset LC_ALL LANG
|
Reference in New Issue
Block a user