Skip to content
41 changes: 41 additions & 0 deletions .github/workflows/end-to-end-test-tracer-replay_testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: end-to-end-test

on:
pull_request:
workflow_dispatch:

jobs:
tracer-replay-testbench:
runs-on: ubuntu-latest
env:
CODEFLASH_AIS_SERVER: prod
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
COLUMNS: 110
MAX_RETRIES: 3
RETRY_DELAY: 5
EXPECTED_IMPROVEMENT_PCT: 10
CODEFLASH_END_TO_END: 1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python 3.11 for CLI
uses: astral-sh/setup-uv@v5
with:
python-version: 3.11.6

- name: Install dependencies (CLI)
run: |
uv tool install poetry
uv venv
source .venv/bin/activate
poetry install --with dev

- name: Run Codeflash to optimize code
id: optimize_code
run: |
source .venv/bin/activate
poetry run python tests/scripts/end_to_end_test_tracer_replay_testbench.py
24 changes: 24 additions & 0 deletions code_to_optimize/code_directories/simple_tracer_e2e/testbench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from concurrent.futures import ThreadPoolExecutor

def funcA(number):
k = 0
for i in range(number * 100):
k += i
# Simplify the for loop by using sum with a range object
j = sum(range(number))

# Use a generator expression directly in join for more efficiency
return " ".join(str(i) for i in range(number))


def test_threadpool() -> None:
pool = ThreadPoolExecutor(max_workers=3)
args = list(range(10, 31, 10))
result = pool.map(funcA, args)

for r in result:
print(r)


if __name__ == "__main__":
test_threadpool()
Loading
Loading