Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
javadsaberlatibari authored Apr 2, 2024
1 parent ec178f9 commit f3c5660
Showing 1 changed file with 42 additions and 25 deletions.
67 changes: 42 additions & 25 deletions wellcoordination/benchmark/rubis-benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
//sellItem 0 2(id+value)
//storeBuyNow 1 2(id+value) by leader
//registerUser 2 1(id) by leader
//openAuction 1(id) by default consider 100 auctions are open.
//placeBid 3 3(auctionid+userid+value)
//query 4 like movie does not consider read.
//openAuction 3 1(id) by default consider 100 auctions are open.
//placeBid 4 3(auctionid+userid+value)
//placeBid 5
//query 6 like movie does not consider read.

int main(int argc, char* argv[]) {
std::string loc =
Expand Down Expand Up @@ -43,8 +44,8 @@ int main(int argc, char* argv[]) {
double total_writes = num_ops * write_percentage;
int queries = num_ops - total_writes;

int num_conflicting_write_methods = 2;
int num_nonconflicting_write_methods = 3;
int num_conflicting_write_methods = 4;
int num_nonconflicting_write_methods = 2;
int num_read_methods = 0;

std::cout << "ops: " << num_ops << std::endl;
Expand Down Expand Up @@ -130,10 +131,44 @@ int main(int argc, char* argv[]) {
}
}
}
// third leader
else if (i == 3) {
for (int type = 0; type <= 1; type++) {
int count = 0;
for (; count < expected_calls_per_update_method;) {
// registerUser
// add users from 100 - 199.
std::string callStr;
if (type == 0) {
// placeBid
// Bid with user id 0 - 99 and item id 0 - 99
std::string a_id = std::to_string(std::rand() % 100); //auction id
std::string u_id = std::to_string(std::rand() % 100); //user id
std::string value = std::to_string(std::rand() % 1000); //bid value

callStr = "3 " + a_id + "-" + u_id + "-" + value;
}
if (type == 1) {
//Close Auctions
std::string i_id = std::to_string(100 + std::rand() % 100); //auction id
//std::string stock = std::to_string(1 + std::rand() % 1000); //stock

//open[i - 1].push_back(i_id);
callStr = "5 " + i_id
}
MethodCall call = ReplicatedObject::createCall("id", callStr);
if (test->isPermissible(call)) {
test->execute(call);
calls[i - 1].push_back(callStr);
count++;
}
}
}
}
// follower
else {
// non-conflicting write method
for (int type = 0; type <= 2; type++) {
for (int type = 0; type <= 1; type++) {
for (int count = 0; count <
expected_nonconflicting_write_calls_per_follower; count++) {
std::string callStr;
Expand All @@ -143,17 +178,8 @@ int main(int argc, char* argv[]) {
std::string value = std::to_string(std::rand() % 1000);
callStr = "0 " + s_id+ "-"+ value;
}
if (type == 1) {
// placeBid
// Bid with user id 0 - 99 and item id 0 - 99
std::string a_id = std::to_string(std::rand() % 100); //auction id
std::string u_id = std::to_string(std::rand() % 100); //user id
std::string value = std::to_string(std::rand() % 1000); //bid value

callStr = "3 " + a_id + "-" + u_id + "-" + value;
}

if (type == 2) {
if (type == 1) {
//Open Auctions
// Open 100 - 199, with different stock values
// Save the opened ids so we can close them after shuffling.
Expand Down Expand Up @@ -189,15 +215,6 @@ int main(int argc, char* argv[]) {
calls[i].insert(calls[i].begin(),
std::string("#" + std::to_string(write_calls)));
std::random_shuffle(calls[i].begin() + 1, calls[i].end());

std::string callStr;
if (i != 0 && i != 1)
for (int count = 0; count < expected_nonconflicting_write_calls_per_follower; count++) {
//Close Auction (using the saved values we opened added to the end of the shuffled operations)
callStr = "5 " + open[i][count];
calls[i].push_back(callStr);
}

}

for (int i = 0; i < nr_procs; i++) {
Expand Down

0 comments on commit f3c5660

Please sign in to comment.