diff --git a/.dockerignore b/.dockerignore index b28e804..2501371 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,8 @@ /build /config.json /users.json -/*.md +/help.md +/services.md +/APIs.md +/README.md +/benchmarking.cpp \ No newline at end of file diff --git a/benchmarking.cpp b/benchmarking.cpp new file mode 100644 index 0000000..2a2f3d0 --- /dev/null +++ b/benchmarking.cpp @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include +#include "bank_f.h" + +#include +#include +#include +#include + +using namespace std::chrono; +using namespace drogon; + +static Bank bank; + +#include +#include +#include + +#define time_func_a(f, a, x) \ + { \ + using namespace std::chrono; \ + uint32_t timer = 0; \ + for (int i = 0; i < x; ++i) \ + { \ + auto t1 = high_resolution_clock::now().time_since_epoch(); \ + f; \ + auto t2 = high_resolution_clock::now().time_since_epoch(); \ + a; \ + timer += std::chrono::duration_cast((t2 - t1)).count(); \ + } \ + std::cout << timer / x << '\n'; \ + } + +#define time_func(f, x) \ + { \ + using namespace std::chrono; \ + uint32_t timer = 0; \ + for (int i = 0; i < x; ++i) \ + { \ + auto t1 = high_resolution_clock::now().time_since_epoch(); \ + f; \ + auto t2 = high_resolution_clock::now().time_since_epoch(); \ + timer += std::chrono::duration_cast((t2 - t1)).count(); \ + } \ + std::cout << timer / x << '\n'; \ + } + +#define Op_a(v, name, x, a) \ + { \ + std::cout << name; \ + time_func_a(v, a, x); \ + } + +#define Op(v, name, x) \ + { \ + std::cout << name; \ + time_func(v, x); \ + } + +int main(int argc, char **argv) +{ + bank.Load(); + bank.admin_pass = "root"; + Op_a(bank.AddUser("", ""), "add user: ", 1000000, bank.DelUser("", "")); + Op_a(bank.AdminAddUser("root", "", 0, ""), "admin add user: ", 1000000, bank.DelUser("", "")); + Op(bank.SetBal("twix", "root", 1000000), "set bal: ", 1000000); + Op(bank.SendFunds("twix", "jolly", 1, "root"), "send funds: ", 1000000); + bank.AddUser("", ""); + Op_a(bank.DelUser("", ""), "del user: ", 1000000, bank.AddUser("", "")); + bank.AddUser("", ""); + Op_a(bank.AdminDelUser("", "root"), "admin del user: ", 1000000, bank.AddUser("", "")); + Op(bank.Contains("twix"), "contains: ", 1000000); + Op(bank.AdminVerifyPass("root"), "admin verify pass: ", 1000000); + Op(bank.GetBal("twix"), "get bal: ", 1000000); + Op(bank.VerifyPassword("twix", "root"), "verify pass: ", 1000000); + Op(bank.ChangePassword("twix", "root", "root"), "change pass: ", 1000000); + Op(bank.GetLogs("twix", "root"), "get logs: ", 1000); + + return 0; +}