def mkres()

in source/benchmark-sample/emr-benchmark.py [0:0]


def mkres(queries, key, fs_protocols, filename, get_name_func=lambda x: x):
    assert iter(queries)
    assert iter(fs_protocols)
    assert callable(get_name_func)
    with open(filename, 'w') as fp:
        label = ','.join(fs_protocols)
        fp.write('# %s %s\n' % (filename, label))
        fp.write('@ %s\n' % label)
        for q in queries:
            resfile = [get_name_func(q, key, ptcl) for ptcl in fs_protocols]
            if not all(os.path.isfile(r) for r in resfile):
                continue
            q = os.path.basename(q)
            d = ','.join('%.2f' % float(fread(r)) for r in resfile)
            fp.write('%s,%s\n' % (q, d))