This commit is contained in:
Evann Regnault 2024-05-31 14:28:54 +00:00
parent d07d511a9f
commit 55a75e9485
3 changed files with 11 additions and 11 deletions

View file

@ -6,7 +6,7 @@ import json
INDEX = "threads" INDEX = "threads"
class Elastic_4_Shards_Testing(DB_Testing): class Elastic_2_Shards_Testing(DB_Testing):
driver_name = "ES (4-Shards)" driver_name = "ES (4-Shards)"
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
@ -31,7 +31,7 @@ class Elastic_4_Shards_Testing(DB_Testing):
'settings': { 'settings': {
'index': { 'index': {
'number_of_replicas': 0, 'number_of_replicas': 0,
'number_of_shards': 4 'number_of_shards': 2
} }
} }
}) })

18
main.py
View file

@ -2,7 +2,7 @@ from elasticsearch import Elasticsearch
from psycopg2 import connect from psycopg2 import connect
from drivers.psql import PSQL_Testing from drivers.psql import PSQL_Testing
from drivers.elastic import Elastic_Testing from drivers.elastic import Elastic_Testing
from drivers.elastic4 import Elastic_4_Shards_Testing from drivers.elastic4 import Elastic_2_Shards_Testing
from sshtunnel import SSHTunnelForwarder from sshtunnel import SSHTunnelForwarder
from utils.utils import preprocess_json from utils.utils import preprocess_json
from typing_extensions import Dict from typing_extensions import Dict
@ -23,22 +23,22 @@ def test_psql():
def test_elasticsearch(): def test_elasticsearch():
es = Elasticsearch( es = Elasticsearch(
'http://elastic-tma.docker.tma.coe.int:80', 'https://127.0.0.1:9200',
api_key='VGxhTnhJOEJGM3NDbkpWLVBzUkg6eHE4c3FuclhTWW1sRm9YN0FkWmRMdw==', api_key='RVAzeHpvOEJXTnUzZ2RiTkdWX2Q6TksySHBfaEFSWktoQmNPOFFSbm1DUQ==',
verify_certs=False, # just to not create certificates verify_certs=False, # just to not create certificates
ssl_show_warn=False ssl_show_warn=False
) )
return Elastic_Testing().do_tests(es) return Elastic_Testing().do_tests(es)
def test_elasticsearch_4_shards(): def test_elasticsearch_2_shards():
es = Elasticsearch( es = Elasticsearch(
'http://elastic-tma.docker.tma.coe.int:80', 'https://127.0.0.1:9200',
api_key='VGxhTnhJOEJGM3NDbkpWLVBzUkg6eHE4c3FuclhTWW1sRm9YN0FkWmRMdw==', api_key='RVAzeHpvOEJXTnUzZ2RiTkdWX2Q6TksySHBfaEFSWktoQmNPOFFSbm1DUQ==',
verify_certs=False, # just to not create certificates verify_certs=False, # just to not create certificates
ssl_show_warn=False ssl_show_warn=False
) )
return Elastic_4_Shards_Testing().do_tests(es) return Elastic_2_Shards_Testing().do_tests(es)
def plot(timings: Dict[str, Dict[str, float]]): def plot(timings: Dict[str, Dict[str, float]]):
@ -77,7 +77,7 @@ def plot(timings: Dict[str, Dict[str, float]]):
plt.text(j + (i * bar_width), v + 0.02, str(round(v, 2)), fontsize=8, ha='center', va='bottom') plt.text(j + (i * bar_width), v + 0.02, str(round(v, 2)), fontsize=8, ha='center', va='bottom')
fig.tight_layout() fig.tight_layout()
plt.savefig("plot-tma-opti.png") plt.savefig("plot-orodruin-opti.png")
plt.show() plt.show()
@ -91,7 +91,7 @@ if __name__ == "__main__":
timings['PSQL'] = test_psql() timings['PSQL'] = test_psql()
timings['ES'] = test_elasticsearch() timings['ES'] = test_elasticsearch()
timings['ES4shards'] = test_elasticsearch_4_shards() timings['ES2shards'] = test_elasticsearch_2_shards()
plot(timings) plot(timings)

BIN
plot-orodruin-opti.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB