Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Summpot committed Nov 9, 2024
1 parent 162989a commit 1d51b7b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.12"
- uses: bencherdev/bencher@main
- name: Install Hatch
uses: pypa/hatch@install
- name: Build with hatch
run: hatch build
- name: Test with pytest
run: hatch run pytest
- name: Benchmark with bencher and pytest
run: |
bencher run \
--project image_interpolation \
--adapter python_pytest \
--file results.json \
--token '${{ secrets.BENCHER_API_TOKEN }}'
--testbed ubuntu-latest \
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
"hatch run pytest"
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --benchmark-autosave --benchmark-min-rounds=20 --benchmark-json=result.json
12 changes: 6 additions & 6 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ fn fibonacci(n: usize) -> u64 {
return n as u64;
}

let mut dp = vec![0; n + 1];
dp[1] = 1;

for i in 2..=n {
dp[i] = dp[i - 1] + dp[i - 2];
let (mut a, mut b) = (0, 1);
for _ in 2..=n {
let next = a + b;
a = b;
b = next;
}

dp[n]
b
}

#[pymodule]
Expand Down

0 comments on commit 1d51b7b

Please sign in to comment.