|
| 1 | +name: bench-test |
| 2 | +on: [push] |
| 3 | + |
| 4 | +concurrency: |
| 5 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 6 | + cancel-in-progress: true |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + project: |
| 14 | + [ |
| 15 | + commonlibrary_rust_ylong_http, |
| 16 | + commonlibrary_rust_ylong_json, |
| 17 | + commonlibrary_rust_ylong_runtime, |
| 18 | + communication_ipc, |
| 19 | + hiviewdfx_hilog, |
| 20 | + hiviewdfx_hisysevent, |
| 21 | + hiviewdfx_hitrace, |
| 22 | + request_request, |
| 23 | + systemabilitymgr_safwk, |
| 24 | + systemabilitymgr_samgr, |
| 25 | + ] |
| 26 | + steps: |
| 27 | + - name: clone repo |
| 28 | + run: git clone https://gitee.com/openharmony/${{ matrix.project }}.git |
| 29 | + |
| 30 | + - name: install dylint |
| 31 | + run: cargo install cargo-dylint dylint-link |
| 32 | + |
| 33 | + - name: add Cargo.toml dylint lib link |
| 34 | + working-directory: ./${{ matrix.project }} |
| 35 | + run: echo -e "\n[workspace.metadata.dylint]\nlibraries = [\n { git = \"https://github.com/trusted-programming/cargo-mate\"},\n]" >> Cargo.toml |
| 36 | + |
| 37 | + - name: add rayon |
| 38 | + working-directory: ./${{ matrix.project }} |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + find . -type f -name "Cargo.toml" | while read -r file; do |
| 42 | + # Check if rayon is already in the dependencies |
| 43 | + if ! grep -qE "^rayon =" "$file"; then |
| 44 | + # Add rayon under the [dependencies] line |
| 45 | + sed -i '/\[dependencies\]/a rayon = "1.8.1"' "$file" |
| 46 | + fi |
| 47 | + done |
| 48 | +
|
| 49 | + - name: lint fix |
| 50 | + working-directory: ./${{ matrix.project }} |
| 51 | + continue-on-error: true |
| 52 | + run: cargo dylint --all --workspace --fix -- --allow-dirty --allow-no-vcs --broken-code --lib |
| 53 | + |
| 54 | + - name: cargo check |
| 55 | + working-directory: ./${{ matrix.project }} |
| 56 | + run: cargo check |
| 57 | + |
| 58 | + - name: git diff |
| 59 | + working-directory: ./${{ matrix.project }} |
| 60 | + run: git diff |
| 61 | + |
| 62 | + - name: par iter count |
| 63 | + working-directory: ./${{ matrix.project }} |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + # Initialize counters |
| 67 | + par_iter_count=0 |
| 68 | + into_par_iter_count=0 |
| 69 | + par_iter_mut_count=0 |
| 70 | +
|
| 71 | + # Iterate over all .rs files in the current directory and subdirectories |
| 72 | + find . -type f -name '*.rs' | while read -r file; do |
| 73 | + # Count occurrences in the current file |
| 74 | + par_iter_count_in_file=$(grep -o '\.par_iter()' "$file" | wc -l) |
| 75 | + into_par_iter_count_in_file=$(grep -o 'into_par_iter()' "$file" | wc -l) |
| 76 | + par_iter_mut_count_in_file=$(grep -o 'par_iter_mut()' "$file" | wc -l) |
| 77 | +
|
| 78 | + # Update total counters |
| 79 | + ((par_iter_count += par_iter_count_in_file)) |
| 80 | + ((into_par_iter_count += into_par_iter_count_in_file)) |
| 81 | + ((par_iter_mut_count += par_iter_mut_count_in_file)) |
| 82 | + done |
| 83 | +
|
| 84 | + # Print results |
| 85 | + echo ".par_iter() occurrences: $par_iter_count" |
| 86 | + echo "into_par_iter() occurrences: $into_par_iter_count" |
| 87 | + echo "par_iter_mut() occurrences: $par_iter_mut_count" |
0 commit comments