Esempio n. 1
0
def main():
    filename = 'data/output.json'
    output_file = 'output/output.txt'

    common.clear_file(output_file)
    common.append_to_file(output_file, display_text(filename, 'interfaces'))
    common.append_to_file(output_file,
                          display_text(filename, 'interfaces_counters'))
Esempio n. 2
0
def run():
    print(' > Testing skip limit pagination')
    common.remove_file(FILE_NAME)
    start_time = time.time()
    _run()
    seconds_elapsed = time.time() - start_time
    time_msg = ('Time elapsed %s (skip limit)' % 
                common.format_time(seconds_elapsed))
    print(time_msg)
    common.append_to_file('times', time_msg)
    print('Data is in %s' % FILE_NAME)
    return FILE_NAME
Esempio n. 3
0
def save():

  (total_inv, wealth, abs_return, ann_return) = perf_data
  sharpe = risk_data
  
  file_data = []
  line_data = str(type) + ',' + str(rank) + ',' + str(total_inv) + ',' + \
    str(wealth) + ',' + str(abs_return) + ',' + str(ann_return) + ',' + str(sharpe)
  file_data.append(line_data)

  ranked_file_path = os.path.join(output_dir, output_file)
  common.append_to_file(ranked_file_path, file_data)
Esempio n. 4
0
def save():

    (total_inv, wealth, abs_return, ann_return) = perf_data
    sharpe = risk_data

    file_data = []
    line_data = str(type) + ',' + str(rank) + ',' + str(total_inv) + ',' + \
      str(wealth) + ',' + str(abs_return) + ',' + str(ann_return) + ',' + str(sharpe)
    file_data.append(line_data)

    ranked_file_path = os.path.join(output_dir, output_file)
    common.append_to_file(ranked_file_path, file_data)
Esempio n. 5
0
def run():
    print(" > Testing pagination using the last document's _id (find/limit)")
    common.remove_file(FILE_NAME)
    start_time = time.time()
    _run()
    seconds_elapsed = time.time() - start_time
    time_msg = ('Time elapsed %s (find limit)' %
                common.format_time(seconds_elapsed))
    print(time_msg)
    common.append_to_file('times', time_msg)
    print('Data is in %s' % FILE_NAME)
    return FILE_NAME
Esempio n. 6
0
def cmp_files(f1_name, f2_name):
    assert f1_name != f2_name
    start_time = time.time()
    print(' > Comparing files (files must be sorted) %s, %s' %
          (f1_name, f2_name))
    res = filecmp.cmp(f1_name, f2_name)
    print('%s equals %s ? : %s' % (f1_name, f2_name, res))
    seconds_elapsed = time.time() - start_time
    time_msg = ('Time elapsed %s (comparing %s and %s)' %
                (common.format_time(seconds_elapsed), f1_name, f2_name))
    print(time_msg)
    common.append_to_file('times', time_msg)
    return res
Esempio n. 7
0
def sort_file(filename):
    print(' > Sorting %s' % filename)
    start_time = time.time()

    with open(filename) as f_in:
        items = [line for line in f_in]
        items.sort()

    filename = '%s_sorted' % filename
    with open(filename, 'w') as f_out:
        f_out.writelines('%s' % ''.join(items))

    print('Sorted result is in %s' % filename)
    seconds_elapsed = time.time() - start_time
    time_msg = ('Time elapsed %s (sorting %s)' %
                (common.format_time(seconds_elapsed), filename))
    print(time_msg)
    common.append_to_file('times', time_msg)
    return filename