From a4c78116861f6d21185d6cc0db777edb3569970f Mon Sep 17 00:00:00 2001 From: David Luevano <55825613+luevano@users.noreply.github.com> Date: Thu, 12 Dec 2019 23:19:13 -0700 Subject: Add benchmarking and fix bug --- benchmarks.txt | 7 +++++++ main.py | 16 ++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 benchmarks.txt diff --git a/benchmarks.txt b/benchmarks.txt new file mode 100644 index 000000000..45ff5ddaf --- /dev/null +++ b/benchmarks.txt @@ -0,0 +1,7 @@ +ml_type tr_size te_size sigma mae time +CM 500 500 1000.0 43.85581118438912 10.458203600000001 +L-JM 500 500 1000.0 23.306555762464523 10.1301297 +CM 1000 500 1000.0 35.99848579852107 30.1420201 +L-JM 1000 500 1000.0 16.234721245433807 29.1719274 +CM 1500 500 1000.0 31.535353227520467 57.1196739 +L-JM 1500 500 1000.0 14.212853687139276 57.751048 diff --git a/main.py b/main.py index f39b9b57b..059fa2213 100644 --- a/main.py +++ b/main.py @@ -82,18 +82,22 @@ def main(): ljm_pipes.append(ljm_recv) p2.start() - for proc in procs: - proc.join() - cm_bench_results = [] ljm_bench_results = [] for cd_pipe, ljd_pipe in zip(cm_pipes, ljm_pipes): cm_bench_results.append(cd_pipe.recv()) ljm_bench_results.append(ljd_pipe.recv()) - for cm, ljm, in zip(cm_bench_results, ljm_bench_results): - print(cm) - print(ljm) + for proc in procs: + proc.join() + + with open('benchmarks.csv', 'w') as save_file: + save_file.write('ml_type,tr_size,te_size,sigma,mae,time\n') + for cm, ljm, in zip(cm_bench_results, ljm_bench_results): + cm_text = ','.join([str(field) for field in cm]) + '\n' + ljm_text = ','.join([str(field) for field in ljm]) + '\n' + save_file.write(cm_text) + save_file.write(ljm_text) # End of program end_time = time.perf_counter() -- cgit v1.2.3-54-g00ecf