def testGetMemoryUsage(self): # - - - - - - - - - - - - - - - - - - - - - - """Test 'get_memory_usage' function.""" x = auxiliary.get_memory_usage() assert (x == None) or (isinstance(x,str) == True) x = auxiliary.get_memory_usage() assert (x == None) or (isinstance(x,str) == True)
print print ' ', index_method.description time1 = time.time() index_method.build() time2 = time.time() index_method.compact() time3 = time.time() print ' Time used (in sec): build: %.4f, compact: %.4f' % \ (time2-time1, time3-time2) memory_usage_str = auxiliary.get_memory_usage() if (memory_usage_str != None): print ' '+memory_usage_str # Calculate complexity and quality measures - - - - - - - - - - - - - - - - # num_rec_pairs = index_method.num_rec_pairs A = data_set1.num_records # Get the number of matches and non-matches in record pair dictionary # m = 0 # Number of matches nm = 0 # Number of non-matches for (rec_id1, rec_id2_set) in index_method.rec_pair_dict.iteritems():
if not os.path.exists(os.path.dirname(log_file_name)): try: os.makedirs(os.path.dirname(log_file_name)) except OSError as exc: if exc.errno != errno.EEXIST: raise log_file = open(log_file_name, 'w') # Calculate total runtime for PP-SPM tot_time = preprocess_time_db + preprocess_time_query + matching_phase_time + masked_matching_phase_time str_tot_time = '%.4f' % tot_time # Calculate total memory usage for PP-SPM memo_usage = auxiliary.get_memory_usage() memo_usage_val = auxiliary.get_memory_usage_val() memo_usage_val = memo_usage_val if memo_usage_val else 0.0 str_mem_usage = '%.4f' % memo_usage_val # write efficiency results into the log file log_file.write(str(str_tot_time) + ',' + str_mem_usage + os.linesep) for query in accuracy_dict: res_list = accuracy_dict[query] log_file.write(query) for res in res_list: log_file.write(',' + str(res)) log_file.write(os.linesep) log_file.close()