Add a slice benchmark
This commit is contained in:
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"python.linting.banditEnabled": false,
|
||||||
|
"python.linting.pylintEnabled": true,
|
||||||
|
"python.linting.enabled": true
|
||||||
|
}
|
||||||
16
bench_slicing.py
Normal file
16
bench_slicing.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
def bytes_slice():
|
||||||
|
"""Slice using normal bytes"""
|
||||||
|
word = b'A' * 1000
|
||||||
|
for i in range(1000):
|
||||||
|
n = word[0:i]
|
||||||
|
|
||||||
|
def memoryview_slice():
|
||||||
|
"""Convert to a memoryview first."""
|
||||||
|
word = memoryview(b'A' * 1000)
|
||||||
|
for i in range(1000):
|
||||||
|
n = word[0:i]
|
||||||
|
|
||||||
|
|
||||||
|
__benchmarks__ = [
|
||||||
|
(bytes_slice, memoryview_slice, "Slicing with memoryview instead of bytes"),
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user