Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mirakaya authored Dec 4, 2024
1 parent e93e3b7 commit f7ca5d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
11 changes: 4 additions & 7 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def add_vals_to_dict(name_tool, max_comp, max_decomp, avg_num_bytes):

new_val_max_comp = max(infos[0], max_comp)
new_val_max_decomp = max(infos[1], max_decomp)
new_avg_num_bytes = infos[2] + avg_num_bytes
new_num_bytes = infos[2] + avg_num_bytes

info_tools[name_tool] = [new_val_max_comp, new_val_max_decomp, new_avg_num_bytes]
info_tools[name_tool] = [new_val_max_comp, new_val_max_decomp, new_num_bytes]


def update_vars(max_comp, max_decomp, num_bytes, time, count, list_vals):
Expand Down Expand Up @@ -162,12 +162,12 @@ def import_files_in_dir(path):
shutil.move("tables_results_" + file_name + ".tsv", path + "/tables_results_" + file_name + ".tsv")

file_results = open("plot_data_mem_comp_size.tsv", "w")
file_results.write("Name tool\tMax_comp_mem\tMax_decomp_mem\tAverage_bytes\n")
file_results.write("Name tool\tMax_comp_mem\tMax_decomp_mem\tSum_of_avg_comp_size\n")

#Get the max compression and decompression memory and the average compression size for each tool (all datasets)
for i in info_tools.keys():
infos = info_tools[i]
file_results.write(i + "\t" + str(infos[0]) + "\t" + str(infos[1]) + "\t" + str(infos[2]) + "\n")
file_results.write(i + "\t" + str(infos[0]) + "\t" + str(infos[1]) + "\t" + str(round(infos[2],3)) + "\n")

file_results.close()

Expand Down Expand Up @@ -206,9 +206,6 @@ def check_correlations():

import_files_in_dir(directory_path) #calculates the basic metrics

'''for i in range(1,11):
calc_weissman(directory_path, tool_weissman, i/10)'''
calc_weissman(directory_path, tool_weissman, 1)

if not os.path.exists(directory_path + "/final_tsv"):
Expand Down
34 changes: 16 additions & 18 deletions src/main_best_weissman.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,28 @@ def calc_weissman(standard_tool, alpha):
# For all tools, do calculations and write to file
for i in file_content:

if first_line == False:
values = i.split("\n")[0].split("\t")
values = i.split("\n")[0].split("\t")

name_tool = values[0]
compressed_size_tool = float(values[1])
time_tool = float(values[2]) * 60 # Convert to seconds (to avoid log(>1))

name_tool = values[0]
compressed_size_tool = float(values[1])
time_tool = float(values[2]) * 60 # Convert to seconds (to avoid log(>1))
compression_ratio = uncompressed_size / compressed_size_tool
compression_ratio_standard = uncompressed_size / number_bytes_standard

compression_ratio = uncompressed_size / compressed_size_tool
compression_ratio_standard = uncompressed_size / number_bytes_standard
weissman_score = alpha * (compression_ratio / compression_ratio_standard) * (math.log10(time_standard) / math.log10(time_tool))

weissman_score = alpha * (compression_ratio / compression_ratio_standard) * (math.log10(time_standard) / math.log10(time_tool))
# "File\tName tool\tWeissman score\tCompression ratio\tCompressed size\tTime\tSize uncompressed file\tTime ratio(time_standard/time_tool)\n"
file_res.write(file + "\t" + name_tool + "\t" + str(round(weissman_score, num_cases)) + "\t" + str(
round(compression_ratio, num_cases)) + "\t" + str(
round(compressed_size_tool, num_cases)) + "\t" + str(round(time_tool, num_cases)) + "\t" + str(
round(uncompressed_size, num_cases)) + "\t" + str(
round(time_standard / time_tool, num_cases)) + "\n")

# "File\tName tool\tWeissman score\tCompression ratio\tCompressed size\tTime\tSize uncompressed file\tTime ratio(time_standard/time_tool)\n"
file_res.write(file + "\t" + name_tool + "\t" + str(round(weissman_score, num_cases)) + "\t" + str(
round(compression_ratio, num_cases)) + "\t" + str(
round(compressed_size_tool, num_cases)) + "\t" + str(round(time_tool, num_cases)) + "\t" + str(
round(uncompressed_size, num_cases)) + "\t" + str(
round(time_standard / time_tool, num_cases)) + "\n")
#Get best values
update_best_val_dictionary(file, name_tool, weissman_score, compression_ratio)

#Get best values
update_best_val_dictionary(file, name_tool, weissman_score, compression_ratio)

else:
first_line = False

file_results = open("best_weissman_comp_ratios.tsv", "w")
file_results.write("File\tName tool\tBest weissman score\tBest compression ratio\n")
Expand Down

0 comments on commit f7ca5d4

Please sign in to comment.