mirror of
https://github.com/Steffo99/appunti-magistrali.git
synced 2024-11-22 18:44:17 +00:00
19 lines
300 B
Markdown
19 lines
300 B
Markdown
---
|
|
aliases: ["benchmark", "bench"]
|
|
---
|
|
|
|
[[test]] che misura e verifica l'efficienza della [[soluzione]].
|
|
|
|
## Esempio
|
|
|
|
```python
|
|
from time import time_ns
|
|
from .calculator import add
|
|
|
|
def bench_add_1000():
|
|
start = time_ns()
|
|
for i in range(1000):
|
|
add(i, i)
|
|
end = time_ns()
|
|
return end - start
|
|
```
|