skiplist benchmark
This commit is contained in:
parent
34c8adbcb9
commit
f5cf9c72d2
@ -376,6 +376,8 @@ option(TOOLS "Build tool executables" ON)
|
|||||||
message(STATUS "TOOLS binaries: ${TOOLS}")
|
message(STATUS "TOOLS binaries: ${TOOLS}")
|
||||||
option(TESTS "Build test binaries" ON)
|
option(TESTS "Build test binaries" ON)
|
||||||
message(STATUS "TESTS binaries: ${TESTS}")
|
message(STATUS "TESTS binaries: ${TESTS}")
|
||||||
|
option(BENCHMARK "Build benchmark binaries" ON)
|
||||||
|
message(STATUS "BENCHMARK binaries: ${BENCHMARK}")
|
||||||
# -- binaries -----------------------------------------------------------------
|
# -- binaries -----------------------------------------------------------------
|
||||||
# -- barrier - this is the way how the engine is isolated so it can be shipped
|
# -- barrier - this is the way how the engine is isolated so it can be shipped
|
||||||
# wherever, the code is completely hidden behind the barrier, during the
|
# wherever, the code is completely hidden behind the barrier, during the
|
||||||
@ -511,6 +513,10 @@ if (POC)
|
|||||||
add_subdirectory(poc)
|
add_subdirectory(poc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# benchmark binaries
|
||||||
|
if (BENCHMARK)
|
||||||
|
add_subdirectory(benchmark)
|
||||||
|
endif()
|
||||||
|
|
||||||
# memgraph build name
|
# memgraph build name
|
||||||
execute_process(
|
execute_process(
|
||||||
|
8
benchmark/CMakeLists.txt
Normal file
8
benchmark/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
|
||||||
|
project(memgraph_benchmark)
|
||||||
|
|
||||||
|
add_executable(skiplist_benchmark skiplist.cpp)
|
||||||
|
target_link_libraries(skiplist_benchmark Threads::Threads)
|
||||||
|
target_link_libraries(skiplist_benchmark memgraph)
|
||||||
|
target_link_libraries(skiplist_benchmark ${fmt_static_lib})
|
29
benchmark/skiplist.cpp
Normal file
29
benchmark/skiplist.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "data_structures/concurrent/skiplist.hpp"
|
||||||
|
#include "utils/time/timer.hpp"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
SkipList<int> skiplist;
|
||||||
|
|
||||||
|
// insert a bunch of elements
|
||||||
|
{
|
||||||
|
int iters_no = 1000000;
|
||||||
|
auto skiplist_accessor = skiplist.access();
|
||||||
|
Stopwatch sw;
|
||||||
|
|
||||||
|
sw.Start();
|
||||||
|
for (int i = 0; i < iters_no; ++i)
|
||||||
|
{
|
||||||
|
skiplist_accessor.insert(std::move(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Skiplist contains: "
|
||||||
|
<< skiplist_accessor.size()
|
||||||
|
<< " elements"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -4,5 +4,5 @@ barrier_template_cpu_cpp_path: "./template/barrier_template_code_cpu.cpp"
|
|||||||
template_cpu_hpp_path: "./template/template_code_cpu.hpp"
|
template_cpu_hpp_path: "./template/template_code_cpu.hpp"
|
||||||
snapshots_path: "snapshots"
|
snapshots_path: "snapshots"
|
||||||
cleaning_cycle_sec: "300"
|
cleaning_cycle_sec: "300"
|
||||||
snapshot_cycle_sec: "3600"
|
snapshot_cycle_sec: "60"
|
||||||
max_retained_snapshots: "3"
|
max_retained_snapshots: "3"
|
||||||
|
@ -22,3 +22,47 @@ auto timer(F func, Args &&... args)
|
|||||||
func(std::forward<Args>(args)...);
|
func(std::forward<Args>(args)...);
|
||||||
return to_duration<DurationUnit>(time_now() - start_time);
|
return to_duration<DurationUnit>(time_now() - start_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// idea from Optimized C++ Kurt Guntheroth 2016
|
||||||
|
// TODO: make more modular and easier to use
|
||||||
|
class Stopwatch
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Stopwatch() : start(std::chrono::system_clock::time_point::min()) {}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
start = std::chrono::system_clock::time_point::min();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsStarted() const
|
||||||
|
{
|
||||||
|
return (start != std::chrono::system_clock::time_point::min());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
start = std::chrono::system_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long GetMs()
|
||||||
|
{
|
||||||
|
if (IsStarted())
|
||||||
|
{
|
||||||
|
std::chrono::system_clock::duration diff;
|
||||||
|
diff = std::chrono::system_clock::now() - start;
|
||||||
|
return (unsigned) (std::chrono::duration_cast<ms>(diff).count());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Stopwatch()
|
||||||
|
{
|
||||||
|
std::cout << "Time: " << GetMs() << "ms" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::chrono::system_clock::time_point start;
|
||||||
|
|
||||||
|
};
|
||||||
|
@ -11,11 +11,11 @@ target_link_libraries(poc_astar Threads::Threads)
|
|||||||
target_link_libraries(poc_astar ${fmt_static_lib})
|
target_link_libraries(poc_astar ${fmt_static_lib})
|
||||||
target_link_libraries(poc_astar ${yaml_static_lib})
|
target_link_libraries(poc_astar ${yaml_static_lib})
|
||||||
|
|
||||||
add_executable(profile profile.cpp)
|
add_executable(powerlinx_profile profile.cpp)
|
||||||
target_link_libraries(profile memgraph)
|
target_link_libraries(powerlinx_profile memgraph)
|
||||||
target_link_libraries(profile Threads::Threads)
|
target_link_libraries(powerlinx_profile Threads::Threads)
|
||||||
target_link_libraries(profile ${fmt_static_lib})
|
target_link_libraries(powerlinx_profile ${fmt_static_lib})
|
||||||
target_link_libraries(profile ${yaml_static_lib})
|
target_link_libraries(powerlinx_profile ${yaml_static_lib})
|
||||||
|
|
||||||
add_executable(csv_import csv_import.cpp)
|
add_executable(csv_import csv_import.cpp)
|
||||||
target_link_libraries(csv_import memgraph)
|
target_link_libraries(csv_import memgraph)
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
#include "profile.hpp"
|
|
||||||
|
|
||||||
#include "barrier/barrier.cpp"
|
|
||||||
|
|
||||||
#include "database/db.hpp"
|
|
||||||
#include "database/db_accessor.hpp"
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "barrier/barrier.cpp"
|
||||||
|
#include "database/db.hpp"
|
||||||
|
#include "database/db_accessor.hpp"
|
||||||
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
|
||||||
#include "import/csv_import.hpp"
|
#include "import/csv_import.hpp"
|
||||||
#include "logging/default.hpp"
|
#include "logging/default.hpp"
|
||||||
#include "logging/streams/stdout.hpp"
|
#include "logging/streams/stdout.hpp"
|
||||||
#include "utils/command_line/arguments.hpp"
|
#include "utils/command_line/arguments.hpp"
|
||||||
|
#include "profile.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
// (company, {type_name, score})
|
||||||
using company_profile_type =
|
using company_profile_type =
|
||||||
pair<barrier::VertexAccessor, unordered_map<string, double>>;
|
pair<barrier::VertexAccessor, unordered_map<string, double>>;
|
||||||
|
|
||||||
// Accepts flags for csv import.
|
// Accepted flags for CSV import.
|
||||||
// -db name # will create database with that name.
|
// -db name # will create database with that name.
|
||||||
// -s true # will create snapshot of the database after import.
|
// -s true # will create snapshot of the database after import.
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
// initialize logger
|
||||||
logging::init_async();
|
logging::init_async();
|
||||||
logging::log->pipe(std::make_unique<Stdout>());
|
logging::log->pipe(std::make_unique<Stdout>());
|
||||||
|
|
||||||
|
// read program arguments
|
||||||
auto para = all_arguments(argc, argv);
|
auto para = all_arguments(argc, argv);
|
||||||
Db db(get_argument(para, "-db", "powerlinks_profile"));
|
Db db(get_argument(para, "-db", "powerlinks_profile"));
|
||||||
|
|
||||||
|
// import database
|
||||||
import_csv_from_arguments(db, para);
|
import_csv_from_arguments(db, para);
|
||||||
|
|
||||||
{
|
{
|
||||||
DbAccessor t(db);
|
DbAccessor t(db);
|
||||||
|
|
||||||
vector<company_profile_type> company_profiles;
|
vector<company_profile_type> company_profiles;
|
||||||
|
|
||||||
// QUERY BENCHMARK
|
// query benchmark
|
||||||
auto begin = clock();
|
auto begin = clock();
|
||||||
int n = for_all_companys(barrier::trans(t), company_profiles);
|
int n = for_all_companys(barrier::trans(t), company_profiles);
|
||||||
clock_t end = clock();
|
clock_t end = clock();
|
||||||
@ -51,6 +51,7 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// performance statistics
|
||||||
cout << endl
|
cout << endl
|
||||||
<< "Query duration: " << (elapsed_s / n) * 1000 * 1000 << " [us]"
|
<< "Query duration: " << (elapsed_s / n) * 1000 * 1000 << " [us]"
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -67,8 +68,8 @@ int main(int argc, char **argv)
|
|||||||
int company_id = std::stoi(get_argument(para, "-company_id", "230216"));
|
int company_id = std::stoi(get_argument(para, "-company_id", "230216"));
|
||||||
for (auto &company_profile : company_profiles) {
|
for (auto &company_profile : company_profiles) {
|
||||||
auto prop_vertex_id = t.vertex_property_key<Int64>("company_id");
|
auto prop_vertex_id = t.vertex_property_key<Int64>("company_id");
|
||||||
auto db_company_id = *barrier::trans(company_profile.first)
|
auto db_company_id =
|
||||||
.at(prop_vertex_id).get();
|
*barrier::trans(company_profile.first).at(prop_vertex_id).get();
|
||||||
if (db_company_id == company_id) {
|
if (db_company_id == company_id) {
|
||||||
cout << endl << "CompanyID: " << company_id << endl;
|
cout << endl << "CompanyID: " << company_id << endl;
|
||||||
for (auto e : company_profile.second) {
|
for (auto e : company_profile.second) {
|
||||||
@ -77,20 +78,13 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// double sum = 0;
|
|
||||||
// for (auto r : coll) {
|
|
||||||
// for (auto e : r.second) {
|
|
||||||
// sum += e.second;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// cout << endl << endl << "Compiler sum " << sum << endl;
|
|
||||||
|
|
||||||
t.commit();
|
t.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_argument(para, "-s", "false") == "true") {
|
if (get_argument(para, "-s", "false") == "true") {
|
||||||
db.snap_engine.make_snapshot();
|
db.snap_engine.make_snapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
// usleep(1000 * 1000 * 60);
|
// usleep(1000 * 1000 * 60);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user