mirror of
https://github.com/Expand-sys/CCash
synced 2026-03-22 20:47:10 +11:00
✨ benchmarking program
This commit is contained in:
parent
aa9f481fbe
commit
96c6ac07d5
2 changed files with 88 additions and 1 deletions
|
|
@ -1,4 +1,8 @@
|
||||||
/build
|
/build
|
||||||
/config.json
|
/config.json
|
||||||
/users.json
|
/users.json
|
||||||
/*.md
|
/help.md
|
||||||
|
/services.md
|
||||||
|
/APIs.md
|
||||||
|
/README.md
|
||||||
|
/benchmarking.cpp
|
||||||
83
benchmarking.cpp
Normal file
83
benchmarking.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "bank_f.h"
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
using namespace drogon;
|
||||||
|
|
||||||
|
static Bank bank;
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
#include <ratio>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
#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<std::chrono::nanoseconds>((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<std::chrono::nanoseconds>((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;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue