def used_memory_readable() -> str: """ Get the memory usage of the current process in a human-readable format. :return: Memory usage of the current process. """ return get_readable_size(used_memory(1))
def test_standard_query(tmpdir, test_standard): mem1 = used_memory(1) print(used_memory_readable()) with NumpyIndexer.load(os.path.join(tmpdir, 'a.bin')) as ni: ni.batch_size = 256 print(used_memory_readable()) print(ni.raw_ndarray.shape) print(used_memory_readable()) with TimeContext('query topk') as ti: result = ni.query(queries, top_k=10) mem2 = used_memory(1) print(used_memory_readable()) print(result[0].shape) with open(summary_file, 'a') as fp: json.dump( { 'name': 'naive', 'memory': mem2 - mem1, 'readable': get_readable_size(mem2 - mem1), 'time': ti.duration }, fp) fp.write('\n')