aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/perf.yml
blob: f58b74ba0fce8fd84de535c7953b0ad51bc63146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Perf

on: [push, pull_request]

env:
  LLVM_CONFIG: /usr/bin/llvm-config-14
  PS_PACKAGES: libps4000 libps5000 libps6000
  GMP_PACKAGES: libgmp-dev libmpfr-dev libmpc-dev
  FLINT_PACKAGES: libflint-dev
  OTHER_PACKAGES: swig gcc libpcsclite-dev llvm-14 libllvm14 llvm-14-dev libpari-dev pari-gp pari-seadata

jobs:
  perf:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.9", "3.10", "3.11", "3.12"]
        mod: ["python", "gmp", "flint"]
    env:
      PYTHON: ${{ matrix.python-version }}
      MOD_IMPL: ${{ matrix.mod }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: pip-${{ runner.os }}-${{ matrix.mod }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
          restore-keys: |
            pip-${{ runner.os }}-${{ matrix.mod }}-${{ matrix.python-version }}-
            pip-${{ runner.os }}-${{ matrix.mod }}-
            pip-${{ runner.os }}-
      - name: Setup Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: Add picoscope repository
        run: |
          curl "https://labs.picotech.com/debian/dists/picoscope/Release.gpg.key" | sudo apt-key add
          sudo echo "deb https://labs.picotech.com/debian/ picoscope main" | sudo tee /etc/apt/sources.list.d/picoscope.list
          sudo apt-get update
      - name: Install system dependencies
        run: |
          sudo apt-get install -y $PS_PACKAGES $OTHER_PACKAGES
          if [ $MOD_IMPL == "gmp" ]; then sudo apt-get install -y $GMP_PACKAGES; fi
          if [ $MOD_IMPL == "flint" ]; then sudo apt-get install -y $FLINT_PACKAGES; fi
      - name: Install picoscope bindings
        run: |
          python -m pip install -U pip setuptools wheel
          git clone https://github.com/colinoflynn/pico-python && cd pico-python && pip install . && cd ..
          git clone https://github.com/picotech/picosdk-python-wrappers && cd picosdk-python-wrappers && pip install . && cd ..
      - name: Install
        run: |
          if [ $MOD_IMPL == "gmp" ];    then pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, pari, leia, gmp, test, dev]"; fi
          if [ $MOD_IMPL == "flint" ];  then pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, pari, leia, flint, test, dev]"; fi
          if [ $MOD_IMPL == "python" ]; then pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, pari, leia, test, dev]"; fi
      - name: Perf
        run: |
          make perf
      - name: Archive perf results
        uses: actions/upload-artifact@v4
        with:
          name: perf-results-${{ matrix.mod }}-${{ matrix.python-version }}
          include-hidden-files: true
          path:
            .perf/
  merge:
    runs-on: ubuntu-latest
    needs: perf
    steps:
      - name: Download perf results
        uses: actions/download-artifact@v4
      - name: Merge
        run: |
          mkdir out
          for dir in */; do if [ "$dir" != "out/" ]; then echo $dir; for f in "$dir"*; do fname=$(basename $f); echo $fname; cat $f >> out/$fname; done; fi; done
      - name: Upload merged
        uses: actions/upload-artifact@v4
        with:
          name: perf-results
          path:
            out
      - name: Delete old
        uses: geekyeggo/delete-artifact@v5
        with:
          name: |
              perf-results-*