Skip to content
Snippets Groups Projects
Commit fd2547de authored by Stephan Porada's avatar Stephan Porada :speech_balloon:
Browse files

Add compression of result dictionary and size infos for other compression or no compression methods

parent e6b27b09
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ from .CQiWrapper.CQiWrapper import CQiWrapper
import sys
import gzip
import zlib
import json
'''
' A dictionary containing lists of, with corpus ids associated, Socket.IO
......@@ -64,14 +65,18 @@ def recv_query(message):
analysis_client.query_subcorpus(query)
results = analysis_client.show_query_results(result_len=int(message['hits_per_page']),
context_len=int(message['context']))
# logger.warning('RESULTS: {}'.format(results))
size_internal_dict = sys.getsizeof(results) / 1000000
size_dict_to_str = sys.getsizeof(str(results)) / 1000000
compressed_str = gzip.compress(str(results).encode())
size_dict_to_str_compressed = sys.getsizeof(compressed_str) / 1000000
logger.warning('Size of dict for {} hits per page: {} MB'.format(message['hits_per_page'], size_internal_dict))
logger.warning('Size of dict to string for {} hits per page: {} MB'.format(message['hits_per_page'], size_dict_to_str))
logger.warning('Size of compressed dict to string for {} hits per page: {} MB'.format(message['hits_per_page'], size_dict_to_str_compressed))
socketio.emit('query', compressed_str, room=request.sid)
zlib_compressed = zlib.compress(json.dumps(results).encode('utf-8'))
size_zlib_compressed = sys.getsizeof(zlib_compressed) / 1000000
logger.warning('Internal size of dict for {} hits per page and context len {}: {} MB'.format(message['hits_per_page'], message['context'], size_internal_dict))
logger.warning('Size of dict as raw string for {} hits per page and context len {}: {} MB'.format(message['hits_per_page'], message['context'], size_dict_to_str))
logger.warning('Size of gzip compressed dict to string for {} hits per page and context len {}: {} MB'.format(message['hits_per_page'], message['context'], size_dict_to_str_compressed))
logger.warning('Size of zlib compressed and utf-8 encoded string for {} hits per page and context len {}: {} MB'.format(message['hits_per_page'], message['context'], size_zlib_compressed))
socketio.emit('query', zlib_compressed, room=request.sid)
def observe_corpus_analysis_connection(app, corpus_id, session_id):
......
This diff is collapsed.
......@@ -19,6 +19,7 @@
<script src="{{ url_for('static', filename='js/CorpusList.js') }}"></script>
<script src="{{ url_for('static', filename='js/JobList.js') }}"></script>
<script src="{{ url_for('static', filename='js/darkreader.js') }}"></script>
<script src="{{ url_for('static', filename='js/pako.js') }}"></script>
<script>
{% if current_user.is_dark == True %}
DarkReader.enable({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment