Skip to content

Commit

Permalink
feat: 优化编译线程数计算算法
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jun 17, 2024
1 parent 1f2a32f commit 634a9a3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/calculate_j.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
# 计算 j 值(通用)
calculate_j() {
export LC_ALL=C
total=$(free -m | awk '/^Mem:/{print $2}')
mem=$(free -m | awk '/^Mem:/{print $2}')
swap=$(free -m | awk '/^Swap:/{print $2}')
total=$((mem + swap))
j_value=$((total / 1024))
cpu_cores=$(nproc)

Expand All @@ -39,7 +41,9 @@ calculate_j() {
# 计算 j 值(2倍内存)
calculate_j2() {
export LC_ALL=C
total=$(free -m | awk '/^Mem:/{print $2}')
mem=$(free -m | awk '/^Mem:/{print $2}')
swap=$(free -m | awk '/^Swap:/{print $2}')
total=$((mem + swap))
j_value=$((total / 2024))
cpu_cores=$(nproc)

Expand Down

0 comments on commit 634a9a3

Please sign in to comment.