Parcourir la source

Added more configuration and testing

master
Ludovic 'Archivist' Lagouardette il y a 5 ans
Parent
révision
ae9b8e93f7
3 fichiers modifiés avec 57 ajouts et 30 suppressions
  1. +1
    -1
      Makefile
  2. +49
    -27
      src/izaro-storage.cpp
  3. +7
    -2
      src/test_client.cpp

+ 1
- 1
Makefile Voir le fichier

@ -21,7 +21,7 @@
CXX := -clang++
DEBUG := -g -O2 -DUNITTEST
DEBUG := -g -O0 -DUNITTEST
RELEASE := -s -O3 -fno-rtti
CXXFLAGS := $(DEBUG) -Wno-unknown-warning-option -Wno-address-of-packed-member -pedantic-errors -Wall -Wextra -Werror -Wfatal-errors -std=c++17 -m64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE

+ 49
- 27
src/izaro-storage.cpp Voir le fichier

@ -21,9 +21,53 @@ int main(
[[maybe_unused]] char** argv
)
{
CMD::commander cmd_args(argc, argv);
std::string database_str = "/data/";
if(cmd_args.isFlagSet("-database"))
{
database_str = cmd_args.getFlagValue("-database");
}
std::string utest_str = "/tmp/";
if(cmd_args.isFlagSet("-utest"))
{
utest_str = cmd_args.getFlagValue("-utest");
}
size_t database_size = 4096;
if(cmd_args.isFlagSet("-page-count"))
{
try{
database_size = std::stoll(cmd_args.getFlagValue("-page-count"));
} catch (...) {
std::cerr << "Invalid page-count value" << std::endl;
return 1;
}
}
size_t utest_size = 4096;
if(cmd_args.isFlagSet("-utest-count"))
{
try{
utest_size = std::stoll(cmd_args.getFlagValue("-utest-count"));
} catch (...) {
std::cerr << "Invalid utest-count value" << std::endl;
return 1;
}
}
#ifdef UNITTEST
{
database db(database::create("/tmp/", 4096));
database db(database::create(n">utest_str, utest_size*2));
db_page v;
v.fill(1);
@ -32,14 +76,13 @@ int main(
auto begin = std::chrono::high_resolution_clock::now();
size_t tot = 2048;
for(size_t idx=0;idx<tot;idx++)
for(size_t idx=0;idx<utest_size;idx++)
{
tar.y.internal = idx;
db.write(tar, v);
}
auto durr = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - begin)/tot;
auto durr = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - begin)/utest_size;
std::cerr << "durr/elem = " << durr.count() << "ns/op" << std::endl;
@ -71,7 +114,7 @@ int main(
db.write(tar, v);
}
database reop(database::open(sa">"/tmp/"));
database reop(database::open(n">utest_str));
{
a = reop.read(tar);
@ -101,27 +144,6 @@ int main(
}
#endif
CMD::commander cmd_args(argc, argv);
std::string database_str = "/data/";
if(cmd_args.isFlagSet("-database"))
{
database_str = cmd_args.getFlagValue("-database");
}
size_t database_size = 4096;
if(cmd_args.isFlagSet("-page-count"))
{
try{
database_size = std::stoll(cmd_args.getFlagValue("-page-count"));
} catch (...) {
std::cerr << "Invalid page-count value" << std::endl;
return 1;
}
}
if(cmd_args.isFlagSet("-create"))
{
@ -192,7 +214,7 @@ int main(
run_db.write(recv.identifier, recv.page);
reply.identifier = recv.identifier;
} catch (...) {
std::cerr << "cluster overfull"<< std::endl;
}
reply_size = sizeof(reply.rep_id) + sizeof(reply.identifier);
}

+ 7
- 2
src/test_client.cpp Voir le fichier

@ -3,7 +3,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
int main() {
int main(kt">int, char** argv) {
{
auto soc = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in server;
@ -11,6 +11,12 @@ int main() {
server.sin_addr.s_addr = *(in_addr_t*)std::array<unsigned char, 4>{127,0,0,1}.data();
server.sin_port = htons(20450);
uint32_t tot = 2048;
if(argv[1])
{
tot = std::stoi(argv[1]);
}
connect(soc, (struct sockaddr*)&server, sizeof(server));
@ -24,7 +30,6 @@ int main() {
auto begin = std::chrono::high_resolution_clock::now();
size_t tot = 2048;
for(size_t idx=0;idx<tot;idx++)
{
tar.y.internal = idx;

Chargement…
Annuler
Enregistrer