libpep 0.12.0

Library for polymorphic encryption and pseudonymization
Documentation
name: Elaborate Benchmarks

on:
  workflow_dispatch:
    inputs:
      sample_size:
        description: 'Sample size for benchmarks'
        required: false
        default: '50'
        type: string

jobs:
  benchmark:
    name: Elaborate Benchmarks
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Setup Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Run elaborate benchmarks
        run: cargo bench --bench distributed --bench energy_distributed -- --output-format bencher | tee benchmark_output.txt

      - name: Parse and display distributed operation results
        run: |
          mkdir -p benchmark_tables

          echo "## Distributed Transcryption Benchmarks" >> $GITHUB_STEP_SUMMARY
          echo "" >> $GITHUB_STEP_SUMMARY
          echo "| Servers | Entities | Pseudonyms | Attributes | Individual (μs) | Batch (μs) |" >> $GITHUB_STEP_SUMMARY
          echo "|---------|----------|------------|------------|-----------------|------------|" >> $GITHUB_STEP_SUMMARY

          # Also write to file
          echo "| Servers | Entities | Pseudonyms | Attributes | Individual (μs) | Batch (μs) |" > benchmark_tables/distributed_transcryption.md
          echo "|---------|----------|------------|------------|-----------------|------------|" >> benchmark_tables/distributed_transcryption.md

          # Create temporary files for storing results
          touch /tmp/individual_results.txt
          touch /tmp/batch_results.txt

          # Parse distributed_transcrypt_complete results
          grep "^test distributed_transcrypt_complete" benchmark_output.txt | while read -r line; do
            benchmark=$(echo "$line" | awk '{print $2}')
            time=$(echo "$line" | awk '{print $5}' | sed 's/,//g')

            # Extract parameters from benchmark name (format: distributed_transcrypt_complete/1servers_1entities_1p_0a)
            params=$(echo "$benchmark" | sed 's/.*\/\([0-9]*\)servers_\([0-9]*\)entities_\([0-9]*\)p_\([0-9]*\)a/\1 \2 \3 \4/')
            servers=$(echo $params | awk '{print $1}')
            entities=$(echo $params | awk '{print $2}')
            pseudonyms=$(echo $params | awk '{print $3}')
            attributes=$(echo $params | awk '{print $4}')

            # Convert ns to μs
            time_us=$(awk "BEGIN {printf \"%.2f\", $time / 1000}")

            echo "${servers}|${entities}|${pseudonyms}|${attributes}|${time_us}" >> /tmp/individual_results.txt
          done

          # Parse distributed_transcrypt_batch results
          grep "^test distributed_transcrypt_batch" benchmark_output.txt | while read -r line; do
            benchmark=$(echo "$line" | awk '{print $2}')
            time=$(echo "$line" | awk '{print $5}' | sed 's/,//g')

            # Extract parameters from benchmark name
            params=$(echo "$benchmark" | sed 's/.*\/\([0-9]*\)servers_\([0-9]*\)entities_\([0-9]*\)p_\([0-9]*\)a/\1 \2 \3 \4/')
            servers=$(echo $params | awk '{print $1}')
            entities=$(echo $params | awk '{print $2}')
            pseudonyms=$(echo $params | awk '{print $3}')
            attributes=$(echo $params | awk '{print $4}')

            # Convert ns to μs
            time_us=$(awk "BEGIN {printf \"%.2f\", $time / 1000}")

            echo "${servers}|${entities}|${pseudonyms}|${attributes}|${time_us}" >> /tmp/batch_results.txt
          done

          # Merge results by configuration (match on servers, entities, pseudonyms, and attributes)
          sort /tmp/individual_results.txt > /tmp/individual_sorted.txt
          sort /tmp/batch_results.txt > /tmp/batch_sorted.txt

          awk -F'|' 'NR==FNR { key = $1 FS $2 FS $3 FS $4; indiv[key] = $5; next } { key = $1 FS $2 FS $3 FS $4; if (key in indiv) { print $1 FS $2 FS $3 FS $4 FS indiv[key] FS $5 } }' /tmp/individual_sorted.txt /tmp/batch_sorted.txt | while IFS='|' read -r servers entities pseudonyms attributes individual_time batch_time; do
            echo "| $servers | $entities | $pseudonyms | $attributes | $individual_time | $batch_time |" >> $GITHUB_STEP_SUMMARY
            echo "| $servers | $entities | $pseudonyms | $attributes | $individual_time | $batch_time |" >> benchmark_tables/distributed_transcryption.md
          done

          # Clean up temp files
          rm -f /tmp/individual_results.txt /tmp/batch_results.txt /tmp/individual_sorted.txt /tmp/batch_sorted.txt

      - name: Upload benchmark tables
        uses: actions/upload-artifact@v6
        with:
          name: benchmark-tables-elaborate-${{ github.sha }}
          path: benchmark_tables/
          retention-days: 90

      - name: Upload benchmark results
        uses: actions/upload-artifact@v6
        with:
          name: benchmark-results-elaborate-${{ github.sha }}
          path: target/criterion/
          retention-days: 90