// File: BU-DiSC[P]BF-Shared-Hashing/db.cpp
// Function: db::PrintStat(double, double)
void db::PrintStat(double program_total, double data_load_total)
{
	// log file
	string out_path_cmd = "mkdir -p " + out_path;
	system(out_path_cmd.c_str());
	string file_result = out_path + "result.txt";
	ofstream result_file(file_result);
	result_file << "Total false positives:\t" << total_fp << endl;
	result_file << "Total negatives:\t" << total_n << endl;
	result_file << "FPR:\t" << (double) total_fp/total_n << endl;
	double total = total_duration.count()/tries;
	result_file << "Total query time:\t" << total  << endl;
	total -= data_duration.count()/tries;
	result_file << "Data access time:\t" << data_duration.count()/tries << endl;
	result_file << "Program total time:\t" << program_total/tries << endl;
	result_file << "Data input time:\t" << data_load_total/tries << endl;
	total -= hash_duration.count()/tries;
	result_file << "Hash time:\t" << hash_duration.count()/tries << endl;
	//total -= bs_duration.count()/tries;
	//result_file << "BS time:\t" << bs_duration.count()/tries << endl;
	result_file << "Other time:\t" << total << endl;
	//cout << "Other2 time:\t" << other2_duration.count()/tries << endl;
	
	result_file << endl;


	/*
	for( int i=0 ; i<num_filter_units; i++ ){
		result_file << "qnum " << i << " : " << qnum_histogram->at(i) << endl;
		cout << "qnum " << i << " : " << qnum_histogram->at(i) << endl;
	}*/

	result_file.close();

	return;
}

// Assembly:
subq $0x338, %rsp            # imm = 0x338
movq %rdi, 0x330(%rsp)
movsd %xmm0, 0x328(%rsp)
movsd %xmm1, 0x320(%rsp)
movq 0x330(%rsp), %rdx
movq %rdx, 0xb8(%rsp)
leaq 0x53d2f(%rip), %rsi     # 0x64337
leaq 0x300(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x10ff0
movq 0xc0(%rsp), %rdi
callq 0x6250
movq %rax, %rdi
callq 0x6460
jmp 0x10634
movq 0xb8(%rsp), %rsi
leaq 0x53d4d(%rip), %rdx     # 0x64390
leaq 0x2d0(%rsp), %rdi
callq 0x10f60
jmp 0x10652
leaq 0xd0(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
movl $0x10, %edx
callq 0x68f0
jmp 0x1066e
leaq 0x53d26(%rip), %rsi     # 0x6439b
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0xb0(%rsp)
jmp 0x1068c
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rax
movq 0x1a8(%rax), %rsi
callq 0x6150
movq %rax, 0xa8(%rsp)
jmp 0x106b2
movq 0xa8(%rsp), %rdi
movq 0x6f8e7(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x106c8
leaq 0x53ce4(%rip), %rsi     # 0x643b3
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0xa0(%rsp)
jmp 0x106e6
movq 0xa0(%rsp), %rdi
movq 0xb8(%rsp), %rax
movq 0x198(%rax), %rsi
callq 0x6150
movq %rax, 0x98(%rsp)
jmp 0x1070c
movq 0x98(%rsp), %rdi
movq 0x6f88d(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x10722
leaq 0x53c9c(%rip), %rsi     # 0x643c5
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0x90(%rsp)
jmp 0x10740
movq 0x90(%rsp), %rdi
movq 0xb8(%rsp), %rax
movq 0x1a8(%rax), %xmm0
movaps 0x539c1(%rip), %xmm3    # 0x64120
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x539c5(%rip), %xmm2    # 0x64130
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x198(%rax), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x68d0
movq %rax, 0x88(%rsp)
jmp 0x107a8
movq 0x88(%rsp), %rdi
movq 0x6f7f1(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x107be
movq 0xb8(%rsp), %rdi
addq $0x188, %rdi            # imm = 0x188
callq 0x8060
movss %xmm0, 0x84(%rsp)
jmp 0x107dd
movss 0x84(%rsp), %xmm0
movq 0xb8(%rsp), %rax
cvtsi2ssl 0x230(%rax), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xc8(%rsp)
leaq 0x53bbd(%rip), %rsi     # 0x643cb
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0x78(%rsp)
jmp 0x10822
movq 0x78(%rsp), %rdi
movsd 0xc8(%rsp), %xmm0
callq 0x68d0
movq %rax, 0x70(%rsp)
jmp 0x1083c
movq 0x70(%rsp), %rdi
movq 0x6f760(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x1084f
movq 0xb8(%rsp), %rdi
addq $0x18c, %rdi            # imm = 0x18C
callq 0x8060
movss %xmm0, 0x6c(%rsp)
jmp 0x1086b
movss 0x6c(%rsp), %xmm0
movq 0xb8(%rsp), %rax
cvtsi2ssl 0x230(%rax), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0xc8(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
leaq 0x53b38(%rip), %rsi     # 0x643de
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0x60(%rsp)
jmp 0x108ba
movq 0xb8(%rsp), %rdi
addq $0x18c, %rdi            # imm = 0x18C
callq 0x8060
movss %xmm0, 0x5c(%rsp)
jmp 0x108d6
movq 0x60(%rsp), %rdi
movss 0x5c(%rsp), %xmm0
movq 0xb8(%rsp), %rax
cvtsi2ssl 0x230(%rax), %xmm1
divss %xmm1, %xmm0
callq 0x63f0
movq %rax, 0x50(%rsp)
jmp 0x10901
movq 0x50(%rsp), %rdi
movq 0x6f69b(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x10914
leaq 0x53ad6(%rip), %rsi     # 0x643f1
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0x48(%rsp)
jmp 0x1092f
movq 0x48(%rsp), %rdi
movq 0xb8(%rsp), %rax
movsd 0x328(%rsp), %xmm0
cvtsi2sdl 0x230(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x68d0
movq %rax, 0x40(%rsp)
jmp 0x1095d
movq 0x40(%rsp), %rdi
movq 0x6f63f(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x10970
leaq 0x53a8f(%rip), %rsi     # 0x64406
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0x38(%rsp)
jmp 0x1098b
movq 0x38(%rsp), %rdi
movq 0xb8(%rsp), %rax
movsd 0x320(%rsp), %xmm0
cvtsi2sdl 0x230(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x68d0
movq %rax, 0x30(%rsp)
jmp 0x109b9
movq 0x30(%rsp), %rdi
movq 0x6f5e3(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x109cc
movq 0xb8(%rsp), %rdi
addq $0x190, %rdi            # imm = 0x190
callq 0x8060
movss %xmm0, 0x2c(%rsp)
jmp 0x109e8
movss 0x2c(%rsp), %xmm0
movq 0xb8(%rsp), %rax
cvtsi2ssl 0x230(%rax), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0xc8(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
leaq 0x539f5(%rip), %rsi     # 0x64418
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0x20(%rsp)
jmp 0x10a37
movq 0xb8(%rsp), %rdi
addq $0x190, %rdi            # imm = 0x190
callq 0x8060
movss %xmm0, 0x1c(%rsp)
jmp 0x10a53
movq 0x20(%rsp), %rdi
movss 0x1c(%rsp), %xmm0
movq 0xb8(%rsp), %rax
cvtsi2ssl 0x230(%rax), %xmm1
divss %xmm1, %xmm0
callq 0x63f0
movq %rax, 0x10(%rsp)
jmp 0x10a7e
movq 0x10(%rsp), %rdi
movq 0x6f51e(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x10a91
leaq 0x5398c(%rip), %rsi     # 0x64424
leaq 0xd0(%rsp), %rdi
callq 0x6500
movq %rax, 0x8(%rsp)
jmp 0x10aac
movq 0x8(%rsp), %rdi
movsd 0xc8(%rsp), %xmm0
callq 0x68d0
movq %rax, (%rsp)
jmp 0x10ac5
movq (%rsp), %rdi
movq 0x6f4d8(%rip), %rsi     # 0x7ffa8
callq 0x6540
jmp 0x10ad7
movq 0x6f4ca(%rip), %rsi     # 0x7ffa8
leaq 0xd0(%rsp), %rdi
callq 0x6540
jmp 0x10aed
leaq 0xd0(%rsp), %rdi
callq 0x6720
jmp 0x10afc
leaq 0xd0(%rsp), %rdi
callq 0x6760
leaq 0x2d0(%rsp), %rdi
callq 0x6340
leaq 0x300(%rsp), %rdi
callq 0x6340
addq $0x338, %rsp            # imm = 0x338
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2f8(%rsp)
movl %eax, 0x2f4(%rsp)
jmp 0x10b85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2f8(%rsp)
movl %eax, 0x2f4(%rsp)
jmp 0x10b78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2f8(%rsp)
movl %eax, 0x2f4(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x6760
leaq 0x2d0(%rsp), %rdi
callq 0x6340
leaq 0x300(%rsp), %rdi
callq 0x6340
movq 0x2f8(%rsp), %rdi
callq 0x6850
nop