|
| 1 | +name: Run UnitsNet Benchmarks |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + benchmark-name: |
| 6 | + description: 'A name given for this benchmark' |
| 7 | + required: false |
| 8 | + default: 'UnitsNet Benchmarks' |
| 9 | + runtimes: |
| 10 | + description: 'The runtime version to use (e.g. net472 net48 netcoreapp21 netcoreapp31 netcoreapp50)' |
| 11 | + default: net472 netcoreapp21 netcoreapp50 |
| 12 | + required: true |
| 13 | + exporters: |
| 14 | + description: 'The exporter(s) used for this run (GitHub/StackOverflow/RPlot/CSV/JSON/HTML/XML)' |
| 15 | + required: false |
| 16 | + default: fulljson rplot |
| 17 | + filter: |
| 18 | + description: 'An optional class filter to apply' |
| 19 | + required: false |
| 20 | + default: '*' |
| 21 | + categories: |
| 22 | + description: 'An optional categories filter to apply' |
| 23 | + required: false |
| 24 | + default: '' |
| 25 | + execution-options: |
| 26 | + description: 'Any additional parameters passed to the benchmark' |
| 27 | + required: false |
| 28 | + default: --disableLogFile |
| 29 | + comparison-baseline: |
| 30 | + description: 'Compare against a previous result (expecting a link to *-report-full.json)' |
| 31 | + required: true |
| 32 | + default: 'https://angularsen.github.io/UnitsNet/benchmarks/netcoreapp50/results/UnitsNet.Benchmark.UnitsNetBenchmarks-report-full.json' |
| 33 | + comparison-threshold: |
| 34 | + description: 'The (comparison) threshold for Statistical Test. Examples: 5%, 10ms, 100ns, 1s' |
| 35 | + required: false |
| 36 | + default: '1%' |
| 37 | + comparison-top: |
| 38 | + description: 'Filter the comparison to the top/bottom N results' |
| 39 | + required: false |
| 40 | + default: 10 |
| 41 | + framework: |
| 42 | + description: 'The dotnet-version version to use (e.g. net5.0)' |
| 43 | + default: 'net5.0' |
| 44 | + required: true |
| 45 | +jobs: |
| 46 | + benchmark: |
| 47 | + env: |
| 48 | + OUTPUT_FOLDER: Artifacts/Benchmarks/${{ github.event.inputs.benchmark-name }} |
| 49 | + runs-on: windows-latest |
| 50 | + steps: |
| 51 | + # checkout the current branch |
| 52 | + - uses: actions/checkout@v2 |
| 53 | + |
| 54 | + # we need all frameworks (even if only running one target at a time) |
| 55 | + - uses: actions/setup-dotnet@v1 |
| 56 | + with: |
| 57 | + dotnet-version: '2.1.x' |
| 58 | + |
| 59 | + - uses: actions/setup-dotnet@v1 |
| 60 | + with: |
| 61 | + dotnet-version: '3.1.x' |
| 62 | + |
| 63 | + - uses: actions/setup-dotnet@v1 |
| 64 | + with: |
| 65 | + dotnet-version: '5.0.x' |
| 66 | + |
| 67 | + # executing the benchmark for the current framework(s), placing the result in the output-folder |
| 68 | + - uses: ./.github/actions/run-benchmarks |
| 69 | + with: |
| 70 | + framework: ${{ github.event.inputs.framework }} |
| 71 | + runtimes: ${{ github.event.inputs.runtimes }} |
| 72 | + output-folder: ${{ env.OUTPUT_FOLDER }} |
| 73 | + filter: ${{ github.event.inputs.filter }} |
| 74 | + categories: ${{ github.event.inputs.categories }} |
| 75 | + execution-options: ${{ github.event.inputs.execution-options }} |
| 76 | + |
| 77 | + # saving the current artifact (downloadable until the expiration date of this action) |
| 78 | + - name: Store benchmark result |
| 79 | + uses: actions/upload-artifact@v2 |
| 80 | + with: |
| 81 | + name: ${{ github.event.inputs.benchmark-name }} (${{ github.event.inputs.runtimes }}) |
| 82 | + path: ${{ env.OUTPUT_FOLDER }}/results |
| 83 | + if-no-files-found: error |
| 84 | + |
| 85 | + compare-results: |
| 86 | + if: ${{ endsWith(github.event.inputs.comparison-baseline, '-report-full.json') }} |
| 87 | + env: |
| 88 | + OUPUT_NAME: Baseline vs ${{ github.event.inputs.benchmark-name }} (${{ github.event.inputs.runtimes }}) |
| 89 | + needs: [benchmark] |
| 90 | + runs-on: ubuntu-latest |
| 91 | + steps: |
| 92 | + # The baseline results are downloaded into a 'baseline' folder. |
| 93 | + - name: Download Baseline |
| 94 | + uses: carlosperate/[email protected] |
| 95 | + with: |
| 96 | + file-url: ${{ github.event.inputs.comparison-baseline }} |
| 97 | + location: baseline |
| 98 | + |
| 99 | + # The benchmark results are downloaded into a 'runtime' folder. |
| 100 | + - name: Download Artifacts |
| 101 | + uses: actions/download-artifact@v1 |
| 102 | + with: |
| 103 | + name: ${{ github.event.inputs.benchmark-name }} (${{ github.event.inputs.runtimes }}) |
| 104 | + path: results |
| 105 | + |
| 106 | + # The benchmark comparer is currently taken from dotnet/performance/src/tools/ResultsComparer (hoping that a 'tool' would eventually be made available) |
| 107 | + - name: Download ResultsComparer |
| 108 | + uses: actions/checkout@v2 |
| 109 | + with: |
| 110 | + repository: dotnet/performance |
| 111 | + path: comparer |
| 112 | + |
| 113 | + - uses: actions/setup-dotnet@v1 |
| 114 | + with: |
| 115 | + dotnet-version: '3.1.x' |
| 116 | + |
| 117 | + - run: mkdir -p artifacts |
| 118 | + |
| 119 | + # Executing the comparer, placing the result in a 'comparison' folder (as well as creating a summary from the output) |
| 120 | + - name: Running the ResultsComparer |
| 121 | + env: |
| 122 | + PERFLAB_TARGET_FRAMEWORKS: netcoreapp3.1 |
| 123 | + run: > |
| 124 | + dotnet run --project 'comparer/src/tools/ResultsComparer' -c Release |
| 125 | + --framework netcoreapp31 |
| 126 | + --base baseline --diff results |
| 127 | + --csv "artifacts/${{ env.OUPUT_NAME }}.csv" |
| 128 | + --xml "artifacts/${{ env.OUPUT_NAME }}.xml" |
| 129 | + --threshold ${{ github.event.inputs.comparison-threshold }} |
| 130 | + --top ${{ github.event.inputs.comparison-top }} |
| 131 | + > "artifacts/${{ env.OUPUT_NAME }}.md" |
| 132 | + |
| 133 | + - name: Summary |
| 134 | + run: cat "artifacts/${{ env.OUPUT_NAME }}.md" |
| 135 | + |
| 136 | + # saving the current artifacts (downloadable until the expiration date of this action) |
| 137 | + - name: Store comparison result |
| 138 | + uses: actions/upload-artifact@v2 |
| 139 | + with: |
| 140 | + name: ${{ env.OUPUT_NAME }} |
| 141 | + path: artifacts |
| 142 | + |
0 commit comments