memgraph/poc/astar_query.cpp

72 lines
1.9 KiB
C++
Raw Normal View History

2016-09-13 19:14:16 +08:00
#include <chrono>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <queue>
#include <regex>
#include <sstream>
#include <string>
#include <vector>
#include "communication/bolt/v1/serialization/bolt_serializer.hpp"
#include "data_structures/map/rh_hashmap.hpp"
#include "database/graph_db.hpp"
2016-09-13 19:14:16 +08:00
#include "database/db_accessor.cpp"
#include "database/db_accessor.hpp"
#include "import/csv_import.hpp"
#include "logging/default.hpp"
#include "logging/streams/stdout.hpp"
#include "queries/astar.hpp"
2016-09-13 19:14:16 +08:00
#include "storage/edge_x_vertex.hpp"
#include "storage/edges.cpp"
#include "storage/edges.hpp"
#include "storage/indexes/impl/nonunique_unordered_index.cpp"
#include "storage/model/properties/properties.cpp"
#include "storage/record_accessor.cpp"
#include "storage/vertex_accessor.hpp"
#include "storage/vertices.cpp"
#include "storage/vertices.hpp"
#include "utils/command_line/arguments.hpp"
int main(int argc, char **argv)
{
logging::init_async();
logging::log->pipe(std::make_unique<Stdout>());
std::srand(time(0));
2016-09-13 19:14:16 +08:00
auto para = all_arguments(argc, argv);
Db db("astar");
PlanCPU plan;
int bench_n = 1000;
2016-09-13 19:14:16 +08:00
do
{
2016-09-16 03:19:31 +08:00
double sum = 0;
for (int i = 0; i < bench_n; i++)
{
2016-09-16 03:19:31 +08:00
auto start_vertex_index =
std::rand() % db.graph.vertices.access().size();
2016-09-16 03:19:31 +08:00
auto begin = clock();
plan_args_t args;
2016-09-16 03:19:31 +08:00
args.push_back(Property(Int64(start_vertex_index), Int64::type));
plan.run(db, args, std::cout);
2016-09-13 19:14:16 +08:00
2016-09-16 03:19:31 +08:00
clock_t end = clock();
2016-09-13 19:14:16 +08:00
2016-09-16 03:19:31 +08:00
double elapsed_ms = (double(end - begin) / CLOCKS_PER_SEC) * 1000;
sum += elapsed_ms;
}
std::cout << "\nSearch for best " << limit
2016-09-16 03:19:31 +08:00
<< " results has runing time of:\n avg: " << sum / bench_n
<< " [ms]\n";
} while (true);
2016-09-13 19:14:16 +08:00
return 0;
}