Пример #1
0
def test():
    fn_values = 'values.txt'
    fn_hash = 'hash.txt'
    num_keys = 2 * 1000 * 1000
    val_size = 2000
    num_trials = 100000

    total_size = num_keys * val_size
    print 'file size will be', total_size
    input = sample_data(num_keys, val_size)
    key_value.store(input, fn_values, fn_hash)

    print 'Setting up DataGetter (involves reading in hash)'
    h = key_value.DataGetter(fn_values, fn_hash)

    print 'Begin READING test'
    t = time.time()
    for i in range(num_trials):
        key = random.randrange(num_keys)
        value = h.get(key)
        if len(value) != val_size:
            raise Exception('incomplete data')
        key2 = int(value.split(',')[0])
        if key != key2:
            raise Exception('wrong value returned')
    time_spent = time.time() - t
    average_delay = time_spent / num_trials
    print 'num trials', num_trials
    print 'time spent', time_spent
    print 'avg delay', average_delay
Пример #2
0
def test():
    fns = list(python_files())
    fn_values = 'fs_values.txt'
    fn_hash = 'fs_hash.txt'

    input = sample_data(fns)

    key_value.store(input, fn_values, fn_hash)

    h = key_value.DataGetter(fn_values, fn_hash)
    for fn in fns:
        fn = fn.replace('../', '')
        contents = h.get(fn)
        print '---', len(contents), fn

    print '======= PRINTING OURSELVES'
    print h.get('KeyValue/glorified_tar.py')