-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
1 parent
349cf1c
commit 28fe975
Showing
8 changed files
with
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Performance | ||
=========== | ||
|
||
This directory contains several scripts and tools to test the performance of | ||
the project. |
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,19 @@ | ||
import time | ||
from engineio import packet | ||
|
||
|
||
def test(): | ||
p = packet.Packet(packet.MESSAGE, b'hello world') | ||
start = time.time() | ||
count = 0 | ||
while True: | ||
p = packet.Packet(encoded_packet=p.encode(b64=True)) | ||
count += 1 | ||
if time.time() - start >= 5: | ||
break | ||
return count | ||
|
||
|
||
if __name__ == '__main__': | ||
count = test() | ||
print('binary_b64_packet:', count, 'packets processed.') |
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,19 @@ | ||
import time | ||
from engineio import packet | ||
|
||
|
||
def test(): | ||
p = packet.Packet(packet.MESSAGE, b'hello world') | ||
start = time.time() | ||
count = 0 | ||
while True: | ||
p = packet.Packet(encoded_packet=p.encode()) | ||
count += 1 | ||
if time.time() - start >= 5: | ||
break | ||
return count | ||
|
||
|
||
if __name__ == '__main__': | ||
count = test() | ||
print('binary_packet:', count, 'packets processed.') |
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,19 @@ | ||
import time | ||
from engineio import packet | ||
|
||
|
||
def test(): | ||
p = packet.Packet(packet.MESSAGE, {'hello': 'world'}) | ||
start = time.time() | ||
count = 0 | ||
while True: | ||
p = packet.Packet(encoded_packet=p.encode()) | ||
count += 1 | ||
if time.time() - start >= 5: | ||
break | ||
return count | ||
|
||
|
||
if __name__ == '__main__': | ||
count = test() | ||
print('json_packet:', count, 'packets processed.') |
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,20 @@ | ||
import time | ||
from engineio import packet, payload | ||
|
||
|
||
def test(): | ||
p = payload.Payload( | ||
packets=[packet.Packet(packet.MESSAGE, b'hello world')] * 10) | ||
start = time.time() | ||
count = 0 | ||
while True: | ||
p = payload.Payload(encoded_payload=p.encode()) | ||
count += 1 | ||
if time.time() - start >= 5: | ||
break | ||
return count | ||
|
||
|
||
if __name__ == '__main__': | ||
count = test() | ||
print('payload:', count, 'payloads processed.') |
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,7 @@ | ||
#!/bin/bash | ||
python text_packet.py | ||
python binary_packet.py | ||
python binary_b64_packet.py | ||
python json_packet.py | ||
python payload.py | ||
python server_receive.py |
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,37 @@ | ||
import io | ||
import sys | ||
import time | ||
import engineio | ||
|
||
|
||
def test(eio_version, payload): | ||
s = engineio.Server() | ||
start = time.time() | ||
count = 0 | ||
s.handle_request({ | ||
'REQUEST_METHOD': 'GET', | ||
'QUERY_STRING': eio_version, | ||
}, lambda s, h: None) | ||
sid = list(s.sockets.keys())[0] | ||
while True: | ||
environ = { | ||
'REQUEST_METHOD': 'POST', | ||
'QUERY_STRING': eio_version + '&sid=' + sid, | ||
'CONTENT_LENGTH': '6', | ||
'wsgi.input': io.BytesIO(payload) | ||
} | ||
s.handle_request(environ, lambda s, h: None) | ||
count += 1 | ||
if time.time() - start >= 5: | ||
break | ||
return count | ||
|
||
|
||
if __name__ == '__main__': | ||
eio_version = 'EIO=4' | ||
payload = b'4hello' | ||
if len(sys.argv) > 1 and sys.argv[1] == '3': | ||
eio_version = 'EIO=3' | ||
payload = b'\x00\x06\xff4hello' | ||
count = test(eio_version, payload) | ||
print('server_receive:', count, 'packets received.') |
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,19 @@ | ||
import time | ||
from engineio import packet | ||
|
||
|
||
def test(): | ||
p = packet.Packet(packet.MESSAGE, 'hello world') | ||
start = time.time() | ||
count = 0 | ||
while True: | ||
p = packet.Packet(encoded_packet=p.encode()) | ||
count += 1 | ||
if time.time() - start >= 5: | ||
break | ||
return count | ||
|
||
|
||
if __name__ == '__main__': | ||
count = test() | ||
print('text_packet:', count, 'packets processed.') |