Skip to content

Commit

Permalink
add benchmark update random
Browse files Browse the repository at this point in the history
  • Loading branch information
hggq committed Jan 26, 2024
1 parent fea3d98 commit fff1750
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions controller/src/techempower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,28 @@ std::string techempowerupdates(std::shared_ptr<httppeer> peer)
{
get_num = 500;
}
std::vector<unsigned int> temprand;
for (unsigned int j = 1; j < 10001; j++)
{
temprand.push_back(j);
}
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::shuffle(temprand.begin(), temprand.end(), std::default_random_engine(seed));
// std::default_random_engine generator{std::random_device{}()};
// std::shuffle(temprand.begin(), temprand.end(), generator);

// std::vector<unsigned int> temprand;
// for (unsigned int j = 1; j < 10001; j++)
// {
// temprand.push_back(j);
// }
// unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
// std::shuffle(temprand.begin(), temprand.end(), std::default_random_engine(seed));
auto myworld = orm::World();
myworld.record.clear();
myworld.record.reserve(get_num);
for (unsigned int i = 0; i < get_num; i++)
{
myworld.wheresql.clear();
myworld.where("id", temprand[i]).fetch_append();
myworld.where("id", rand_range(1, 10000)).fetch_append();
if (myworld.effect() > 0)
{
unsigned int j = myworld.record.size() - 1;
myworld.record[j].randomnumber = temprand[i + 2000];
myworld.data.randomnumber = rand_range(1, 10000);
myworld.record[j].randomnumber = myworld.data.randomnumber;
myworld.update("randomnumber");
}
}
myworld.update_batch("");
peer->output = myworld.to_json();
return "";
}
Expand Down

0 comments on commit fff1750

Please sign in to comment.