-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
import pytest | ||
from nnbench import runner | ||
|
||
|
||
def test_argcheck(typecheckfolder: str) -> None: | ||
benchmarks = os.path.join(typecheckfolder, "benchmarks.py") | ||
r = runner.AbstractBenchmarkRunner() | ||
with pytest.raises(TypeError): | ||
r.run(benchmarks, params={"x": 1, "y": "1"}) | ||
with pytest.raises(ValueError): | ||
r.run(benchmarks, params={"x": 1}) | ||
r.run(benchmarks, | ||
params={"x": 1, "y": 1}) | ||
|
||
|
||
def test_raises_erro_on_duplicate_params(typecheckfolder: str) -> None: | ||
benchmarks = os.path.join(typecheckfolder, "duplicate_benchmarks.py") | ||
|
||
with pytest.raises(TypeError): | ||
r = runner.AbstractBenchmarkRunner() | ||
r.run(benchmarks, params={"x": 1, "y": 1}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import nnbench | ||
|
||
|
||
@nnbench.benchmark | ||
def double(x: int) -> int: | ||
return x*2 | ||
|
||
|
||
@nnbench.benchmark | ||
def triple(y: int) -> int: | ||
return y * 3 | ||
|
||
|
||
@nnbench.benchmark | ||
def prod(x: int, y: int) -> int: | ||
return x * y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import nnbench | ||
|
||
|
||
@nnbench.benchmark | ||
def double(x: int) -> int: | ||
return x*2 | ||
|
||
|
||
@nnbench.benchmark | ||
def triple_str(x: str) -> str: | ||
return x * 3 |