Пример #1
0
async def test_search_many_queries(queries=queries, count_request=100, callback=None):
    print(
        "================================>>> {} test_search_many_queries started".format(ids.__len__() * count_request))
    # async test
    tasks = []
    start_time = time.time()
    for query in queries:
        tasks.append(asyncio.ensure_future(da.http_async_connection(lh, loop).search(query, callback)))
    await asyncio.gather(*tasks)
    end_time = time.time()
    async_duration = end_time - start_time
    # sync test
    start_time = time.time()
    for i in range(count_request):
        for id in ids:
            ds.http_connection(lh).delete(id)
    end_time = time.time()
    sync_duration = end_time - start_time
    print("================================>>>async test_search_many_queries finished in {} seconds".format(
        async_duration))
    print(
        "================================>>>sync test_search_many_queries finished in {} seconds".format(sync_duration))
Пример #2
0
async def test_create_many_element(keys=json_elts_keys_list, count_request=100, callback=None):
    print("================================>>> {} test_create_many_element started".format(count_request))
    # async test
    tasks = []
    start_time = time.time()
    for i in range(count_request):
        for key in keys:
            tasks.append(asyncio.ensure_future(da.http_async_connection(lh, loop).create(key, callback)))
    await asyncio.gather(*tasks)
    end_time = time.time()
    async_duration = end_time - start_time
    # sync test
    start_time = time.time()
    for i in range(count_request):
        for key in keys:
            damas_sync.create(key)
    end_time = time.time()
    sync_duration = end_time - start_time
    print("================================>>> async test_create_many_element finished in {} seconds".format(
        async_duration))
    print("================================>>> sync test_create_many_element finished in {} seconds".format(
        sync_duration))
Пример #3
0
async def test_read_many_element(ids=ids, count_request=100, callback=None):
    print("================================>>> {} test_read_many_element started".format(ids.__len__() * count_request))
    # async test
    tasks = []
    start_time = time.time()
    for i in range(count_request):
        for id in ids:
            tasks.append(asyncio.ensure_future(da.http_async_connection(lh, loop).read(id, callback)))
    await asyncio.gather(*tasks)
    end_time = time.time()
    async_duration = end_time - start_time
    # sync test
    start_time = time.time()
    for i in range(count_request):
        for id in ids:
            await da.http_async_connection(lh, loop).read(id)
    end_time = time.time()
    sync_duration = end_time - start_time
    print("================================>>> async test_create_many_element finished in {} seconds".format(
        async_duration))
    print(
        "================================>>> sync test_create_many_element finished in {} seconds".format(
            sync_duration))
Пример #4
0
import asyncio

# from py.async_cli.damas_sync_experimental import http_async_connection
#
import time

import py.async_cli.damas_async as da
import py.damas as ds

lh = 'http://localhost:8090'
urls = [lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh, lh]
loop = asyncio.get_event_loop()
damas_async = da.http_async_connection(lh, loop)
damas_sync = ds.http_connection(lh)

empty_key, element_with_auto_generated_id_key, elt_with_specified_identifier_key, two_elements_key, \
two_elements_using_an_array_as_id_key, graph_edge_element_key = {}, {}, {}, {}, {}, {}

id0, id1, id2, id3, id4 = "", "", "", "", ""
json_elts_keys_list, ids, queries, ids_to_delete, data_back_up = [], [], [], [], []


async def init_data():
    global element_with_auto_generated_id_key, elt_with_specified_identifier_key, \
        two_elements_using_an_array_as_id_key, two_elements_key, graph_edge_element_key
    global id0, id1, id2, id3, id4, ids
    global json_elts_keys_list, ids, queries, data_back_up
    element_with_auto_generated_id_key = {"key1": "value1", "hello": "world"}
    elt_with_specified_identifier_key = {"_id": "/project/folder/file1", "additional_key": "value1"}
    two_elements_key = {"_id": ["identifier1", "identifier2"], "key": "keyvalue"}
    two_elements_using_an_array_as_id_key = {"_id": ["identifier5", "identifier6"], "key": "keyvalue1"}