Skip to content

Commit 7a65210

Browse files
committed
update experiments
1 parent e083b7c commit 7a65210

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

experiment/exp.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ void sse_server_single_filter_time(int round);
3636
void our_server_single_filter_time(int round);
3737
void bench_server_single_filter_time(int round);
3838

39+
/// Benchmark for performing the final join step.
40+
void bench_server_join_time(int round);
41+
3942
/// Benchmark for total time of single value filter.
4043
void ipe_total_single_filter_time(int round);
4144
void sse_total_single_filter_time(int round);

experiment/run.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ int main(){
88

99
// Bench for server side timings.
1010
bench_server_single_filter_time(100);
11+
bench_server_join_time(100);
1112

1213
// Bench for total timings.
1314
bench_total_single_filter_time(100);

experiment/server_join.cpp

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#include "exp.hpp"
2+
3+
size_t TOTAL = 150000 * 1500000;
4+
5+
void bench_server_join_time(const int round){
6+
// Open the output files.
7+
std::ofstream file("server_join_time.txt", std::ios_base::app);
8+
9+
// Read some data.
10+
StrMat order = Helper::read_tbl("data/orders.tbl", 100);
11+
StrMat customer = Helper::read_tbl("data/customer.tbl", 100);
12+
13+
// Create an AES and pairing group object.
14+
const auto _ = BP();
15+
const auto aes = AES();
16+
17+
// Perform encryption (each encryption result is a CharVec).
18+
std::vector<CharMat> encrypted_order, encrypted_customer;
19+
20+
for (auto& each_row : order){
21+
CharMat temp;
22+
for (auto& each_data : each_row)
23+
temp.push_back(aes.encrypt(Helper::str_to_char_vec(each_data)));
24+
encrypted_order.push_back(temp);
25+
}
26+
27+
for (auto& each_row : customer){
28+
CharMat temp;
29+
for (auto& each_data : each_row)
30+
temp.push_back(aes.encrypt(Helper::str_to_char_vec(each_data)));
31+
encrypted_customer.push_back(temp);
32+
}
33+
34+
// Output the title for this section.
35+
file << "Gt equivalence check time" << std::endl;
36+
37+
// The time to check for equivalence.
38+
for (const int selectivity : {2, 4, 6, 8, 10}){
39+
// Create holder for timings.
40+
std::chrono::duration<double, std::milli> time{};
41+
42+
for (int i = 0; i < round; ++i){
43+
// Perform the desired number of checking Gt.
44+
for (size_t j = 0; j < selectivity * TOTAL / 100; ++j){
45+
// Create a random temp value.
46+
Gt temp;
47+
gt_rand(temp.value);
48+
49+
// Check for equivalence.
50+
auto start = std::chrono::high_resolution_clock::now();
51+
std::ignore = Group::cmp_gt(temp, temp);
52+
auto end = std::chrono::high_resolution_clock::now();
53+
time += end - start;
54+
}
55+
56+
// Perform the desired number of checking Gt.
57+
for (size_t j = 0; j < (100 - selectivity) * TOTAL / 100; ++j){
58+
// Create a random temp value.
59+
Gt temp_one, temp_two;
60+
gt_rand(temp_one.value);
61+
gt_rand(temp_two.value);
62+
63+
// Check for equivalence.
64+
auto start = std::chrono::high_resolution_clock::now();
65+
std::ignore = Group::cmp_gt(temp_one, temp_two);
66+
auto end = std::chrono::high_resolution_clock::now();
67+
time += end - start;
68+
}
69+
}
70+
71+
// Output the time.
72+
file << "(" << selectivity << ", " << time.count() / round << ")" << std::endl;
73+
}
74+
75+
// Output the title for this section.
76+
file << std::endl << std::endl << "Join time" << std::endl;
77+
78+
// The time to check for join.
79+
for (const int selectivity : {2, 4, 6, 8, 10}){
80+
// Create holder for timings.
81+
std::chrono::duration<double, std::milli> time{};
82+
83+
for (int i = 0; i < round; ++i){
84+
// Perform the desired number of checking Gt.
85+
for (size_t j = 0; j < selectivity * TOTAL / 100; ++j){
86+
// Get temp encrypted values.
87+
auto temp_order = encrypted_order[j % 100];
88+
auto temp_customer = encrypted_customer[j % 100];
89+
// Check for equivalence.
90+
auto start = std::chrono::high_resolution_clock::now();
91+
temp_order.insert(temp_order.end(), temp_customer.begin() + 1, temp_customer.end());
92+
auto end = std::chrono::high_resolution_clock::now();
93+
time += end - start;
94+
}
95+
}
96+
97+
// Output the time.
98+
file << "(" << selectivity << ", " << time.count() / round << ")" << std::endl;
99+
}
100+
101+
// Close the bilinear pairing group.
102+
BP::close();
103+
}

0 commit comments

Comments
 (0)