Beispiel #1
0
def find_slot(slot_uuid):
    try:
        slot = database.get_slots(slot_uuid)    
        return json.dumps(slot)
    except:
        return None, 500
Beispiel #2
0
    all_ranges = db_api.get_ranges()
    print('Got {} ranges in {} seconds.'.format(len(all_ranges),
                                                time.time() - start_time))
    if len(all_ranges) == 0:
        uuid = uuid4()
        db_api.create_range(0, 10000)
        all_ranges = db_api.get_ranges()
    the_range = all_ranges[0]
    _range = SlotRange(the_range['start'],
                       the_range['end'],
                       the_range['uuid'])
    print('Allocating via nightmare scenario...')
    start_time = time.time()
    for i in range(0, 5000):
        db_api.create_slot(_range.uuid)
    print('Initial allocation of 5000 slots done in {} seconds...'.format(
        time.time() - start_time))
    print('Deallocating every *other* slot...')
    start_time = time.time()
    all_slots = db_api.get_slots(_range.uuid)
    for i in range(0, 5000, 2):
        db_api.deallocate_slot(all_slots[i]['uuid'], 5)
    print('Deallocated 2500 slots in {} seconds...'.format(
        time.time() - start_time))
    time.sleep(1)
    start_time = time.time()
    print('RE-allocating 2500 slots...')
    for i in range(0, 5000, 2):
        db_api.create_slot(_range.uuid)
    print('Done reallocating in {} seconds.'.format(time.time() - start_time))