-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
42 additions
and
4 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,34 @@ | ||
import time | ||
import sys | ||
|
||
import smart_open | ||
from smart_open.bytebuffer import ByteBuffer | ||
|
||
|
||
def raw_bytebuffer_benchmark(): | ||
buffer = ByteBuffer() | ||
|
||
start = time.time() | ||
for _ in range(10_000): | ||
assert buffer.fill([b"X" * 1000]) == 1000 | ||
return time.time() - start | ||
|
||
|
||
def file_read_benchmark(filename): | ||
file = smart_open.open(filename, mode="rb") | ||
|
||
start = time.time() | ||
read = file.read(100_000_000) | ||
end = time.time() | ||
|
||
if len(read) < 100_000_000: | ||
print("File smaller than 100MB") | ||
|
||
return end - start | ||
|
||
|
||
print("Raw ByteBuffer benchmark:", raw_bytebuffer_benchmark()) | ||
|
||
if len(sys.argv) > 1: | ||
bench_result = file_read_benchmark(sys.argv[1]) | ||
print("File read benchmark", bench_result) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = '6.1.0' | ||
__version__ = '6.2.0' | ||
|
||
|
||
if __name__ == '__main__': | ||
|