Skip to content

Commit 79705b9

Browse files
committed
Restore TOTALS
1 parent 09dbece commit 79705b9

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

pymongo/asynchronous/network.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@
6363

6464
_IS_SYNC = False
6565

66-
# TOTAL = []
67-
# TOTAL_WRITE = []
68-
# TOTAL_READ = []
69-
# print(f"TOTALS: {TOTAL, TOTAL_WRITE, TOTAL_READ}")
66+
TOTAL = []
67+
TOTAL_WRITE = []
68+
TOTAL_READ = []
69+
print(f"TOTALS: {TOTAL, TOTAL_WRITE, TOTAL_READ}")
7070

7171

7272
async def command_stream(
@@ -211,13 +211,13 @@ async def command_stream(
211211
read_start = time.monotonic()
212212
reply = await receive_message_stream(conn, request_id)
213213
read_elapsed = time.monotonic() - read_start
214-
# if name == "insert":
215-
# TOTAL.append(write_elapsed + read_elapsed)
216-
# TOTAL_READ.append(read_elapsed)
217-
# TOTAL_WRITE.append(write_elapsed)
218-
# if name == "endSessions":
219-
# print(
220-
# f"AVERAGE READ: {statistics.mean(TOTAL_READ)}, AVERAGE WRITE: {statistics.mean(TOTAL_WRITE)}, AVERAGE ELAPSED: {statistics.mean(TOTAL)}")
214+
if name == "insert":
215+
TOTAL.append(write_elapsed + read_elapsed)
216+
TOTAL_READ.append(read_elapsed)
217+
TOTAL_WRITE.append(write_elapsed)
218+
if name == "endSessions":
219+
print(
220+
f"AVERAGE READ: {statistics.mean(TOTAL_READ)}, AVERAGE WRITE: {statistics.mean(TOTAL_WRITE)}, AVERAGE ELAPSED: {statistics.mean(TOTAL)}")
221221
conn.more_to_come = reply.more_to_come
222222
unpacked_docs = reply.unpack_response(
223223
codec_options=codec_options, user_fields=user_fields

pymongo/network_layer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
from pymongo import ssl_support
3434
from pymongo._asyncio_task import create_task
35+
from pymongo.common import MAX_MESSAGE_SIZE
3536
from pymongo.errors import _OperationCancelled
3637
from pymongo.socket_checker import _errno_from_exception
3738

@@ -74,7 +75,7 @@
7475
class PyMongoProtocol(asyncio.BufferedProtocol):
7576
def __init__(self):
7677
self.transport = None
77-
self._buffer = None
78+
self._buffer = memoryview(bytearray(MAX_MESSAGE_SIZE))
7879
self.expected_length = 0
7980
self.expecting_header = False
8081
self.bytes_read = 0

0 commit comments

Comments
 (0)