better stats.json
This commit is contained in:
parent
4c29892658
commit
3a08b63d8e
2 changed files with 65 additions and 38 deletions
|
@ -223,6 +223,10 @@ int main(int argc, char** argv) {
|
||||||
exit(static_cast<int>(RetCode::NO_INPUT_FEED));
|
exit(static_cast<int>(RetCode::NO_INPUT_FEED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stats stats;
|
||||||
|
double tOsmBuild = 0;
|
||||||
|
std::map<std::string, std::pair<size_t, size_t>> graphDimensions;
|
||||||
|
|
||||||
for (const auto& motCfg : motCfgReader.getConfigs()) {
|
for (const auto& motCfg : motCfgReader.getConfigs()) {
|
||||||
std::string filePost;
|
std::string filePost;
|
||||||
auto usedMots = pfaedle::router::motISect(motCfg.mots, cmdCfgMots);
|
auto usedMots = pfaedle::router::motISect(motCfg.mots, cmdCfgMots);
|
||||||
|
@ -254,7 +258,12 @@ int main(int argc, char** argv) {
|
||||||
osmBuilder.read(cfg.osmPath, motCfg.osmBuildOpts, &graph, box,
|
osmBuilder.read(cfg.osmPath, motCfg.osmBuildOpts, &graph, box,
|
||||||
cfg.gridSize, &restr);
|
cfg.gridSize, &restr);
|
||||||
|
|
||||||
auto tOsmBuild = T_STOP(osmBuild);
|
tOsmBuild += T_STOP(osmBuild);
|
||||||
|
graphDimensions[filePost].first = graph.getNds().size();
|
||||||
|
|
||||||
|
for (const auto& nd : graph.getNds()) {
|
||||||
|
graphDimensions[filePost].second += nd->getAdjListOut().size();
|
||||||
|
}
|
||||||
|
|
||||||
JaccardClassifier statsimiClassifier;
|
JaccardClassifier statsimiClassifier;
|
||||||
|
|
||||||
|
@ -285,7 +294,6 @@ int main(int argc, char** argv) {
|
||||||
&restr, &statsimiClassifier, router, cfg);
|
&restr, &statsimiClassifier, router, cfg);
|
||||||
|
|
||||||
pfaedle::netgraph::Graph ng;
|
pfaedle::netgraph::Graph ng;
|
||||||
Stats stats;
|
|
||||||
|
|
||||||
if (singleTrip) {
|
if (singleTrip) {
|
||||||
mkdir(cfg.dbgOutputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
mkdir(cfg.dbgOutputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||||
|
@ -293,7 +301,7 @@ int main(int argc, char** argv) {
|
||||||
util::geo::output::GeoJsonOutput o(pstr);
|
util::geo::output::GeoJsonOutput o(pstr);
|
||||||
|
|
||||||
auto l = shapeBuilder.shapeL(singleTrip);
|
auto l = shapeBuilder.shapeL(singleTrip);
|
||||||
stats = l.second;
|
stats += l.second;
|
||||||
|
|
||||||
LOG(INFO) << "Outputting path.json...";
|
LOG(INFO) << "Outputting path.json...";
|
||||||
// reproject to WGS84 to match RFC 7946
|
// reproject to WGS84 to match RFC 7946
|
||||||
|
@ -302,38 +310,7 @@ int main(int argc, char** argv) {
|
||||||
o.flush();
|
o.flush();
|
||||||
pstr.close();
|
pstr.close();
|
||||||
} else {
|
} else {
|
||||||
stats = shapeBuilder.shapeify(&ng);
|
stats += shapeBuilder.shapeify(&ng);
|
||||||
}
|
|
||||||
|
|
||||||
// outputting stats
|
|
||||||
|
|
||||||
if (cfg.writeStats) {
|
|
||||||
size_t numEdgs = 0;
|
|
||||||
for (const auto& nd : graph.getNds()) {
|
|
||||||
numEdgs += nd->getAdjListOut().size();
|
|
||||||
}
|
|
||||||
util::json::Dict jsonStats = {
|
|
||||||
{"statistics",
|
|
||||||
util::json::Dict{
|
|
||||||
{"gtfs_num_stations", gtfs[0].getStops().size()},
|
|
||||||
{"gtfs_num_trips", gtfs[0].getTrips().size()},
|
|
||||||
{"graph_nds", graph.getNds().size()},
|
|
||||||
{"graph_edgs", numEdgs},
|
|
||||||
{"num_tries", stats.numTries},
|
|
||||||
{"num_trie_leafs", stats.numTrieLeafs},
|
|
||||||
{"dijkstra_iters", stats.dijkstraIters},
|
|
||||||
{"time_solve", stats.solveTime},
|
|
||||||
{"time_read_osm", tOsmBuild},
|
|
||||||
{"time_read_gtfs", tGtfsBuild},
|
|
||||||
{"time_tot", T_STOP(total)},
|
|
||||||
{"peak-memory", util::readableSize(util::getPeakRSS())},
|
|
||||||
{"peak-memory-bytes", util::getPeakRSS()}}}};
|
|
||||||
|
|
||||||
std::ofstream ofs;
|
|
||||||
ofs.open("stats" + filePost + ".json");
|
|
||||||
util::json::Writer wr(&ofs, 10, true);
|
|
||||||
wr.val(jsonStats);
|
|
||||||
wr.closeAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (router) delete router;
|
if (router) delete router;
|
||||||
|
@ -351,9 +328,10 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
if (cfg.buildTransitGraph) {
|
if (cfg.buildTransitGraph) {
|
||||||
util::geo::output::GeoGraphJsonOutput out;
|
util::geo::output::GeoGraphJsonOutput out;
|
||||||
LOG(INFO) << "Outputting trgraph" + filePost + ".json...";
|
LOG(INFO) << "Outputting trgraph-" + filePost + ".json...";
|
||||||
mkdir(cfg.dbgOutputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
mkdir(cfg.dbgOutputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||||
std::ofstream fstr(cfg.dbgOutputPath + "/trgraph" + filePost + ".json");
|
std::ofstream fstr(cfg.dbgOutputPath + "/trgraph-" + filePost +
|
||||||
|
".json");
|
||||||
out.print(ng, fstr);
|
out.print(ng, fstr);
|
||||||
fstr.close();
|
fstr.close();
|
||||||
}
|
}
|
||||||
|
@ -364,6 +342,40 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// outputting stats
|
||||||
|
if (cfg.writeStats) {
|
||||||
|
util::json::Dict graphSizes;
|
||||||
|
|
||||||
|
for (const auto& gd : graphDimensions) {
|
||||||
|
util::json::Dict a;
|
||||||
|
a["num_nodes"] = gd.second.first;
|
||||||
|
a["num_edges"] = gd.second.second;
|
||||||
|
graphSizes[gd.first] = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
util::json::Dict jsonStats = {
|
||||||
|
{"statistics",
|
||||||
|
util::json::Dict{
|
||||||
|
{"gtfs_num_stations", gtfs[0].getStops().size()},
|
||||||
|
{"gtfs_num_trips", gtfs[0].getTrips().size()},
|
||||||
|
{"graph_dimension", graphSizes},
|
||||||
|
{"num_tries", stats.numTries},
|
||||||
|
{"num_trie_leafs", stats.numTrieLeafs},
|
||||||
|
{"dijkstra_iters", stats.dijkstraIters},
|
||||||
|
{"time_solve", stats.solveTime},
|
||||||
|
{"time_read_osm", tOsmBuild},
|
||||||
|
{"time_read_gtfs", tGtfsBuild},
|
||||||
|
{"time_tot", T_STOP(total)},
|
||||||
|
{"peak-memory", util::readableSize(util::getPeakRSS())},
|
||||||
|
{"peak-memory-bytes", util::getPeakRSS()}}}};
|
||||||
|
|
||||||
|
std::ofstream ofs;
|
||||||
|
ofs.open(cfg.dbgOutputPath + "/stats.json");
|
||||||
|
util::json::Writer wr(&ofs, 10, true);
|
||||||
|
wr.val(jsonStats);
|
||||||
|
wr.closeAll();
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg.feedPaths.size()) {
|
if (cfg.feedPaths.size()) {
|
||||||
try {
|
try {
|
||||||
mkdir(cfg.outputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
mkdir(cfg.outputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||||
|
@ -384,7 +396,8 @@ int main(int argc, char** argv) {
|
||||||
std::string getFileNameMotStr(const MOTs& mots) {
|
std::string getFileNameMotStr(const MOTs& mots) {
|
||||||
std::string motStr;
|
std::string motStr;
|
||||||
for (const auto& mot : mots) {
|
for (const auto& mot : mots) {
|
||||||
motStr += "-" + ad::cppgtfs::gtfs::flat::Route::getTypeString(mot);
|
if (motStr.size()) motStr += "-";
|
||||||
|
motStr += ad::cppgtfs::gtfs::flat::Route::getTypeString(mot);
|
||||||
}
|
}
|
||||||
|
|
||||||
return motStr;
|
return motStr;
|
||||||
|
|
|
@ -27,6 +27,20 @@ struct Stats {
|
||||||
size_t dijkstraIters;
|
size_t dijkstraIters;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline Stats operator+ (const Stats& c1, const Stats& c2) {
|
||||||
|
Stats ret = c1;
|
||||||
|
ret.totNumTrips += c2.totNumTrips;
|
||||||
|
ret.numTries += c2.numTries;
|
||||||
|
ret.solveTime += c2.solveTime;
|
||||||
|
ret.dijkstraIters += c2.dijkstraIters;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Stats& operator+= (Stats& c1, const Stats& c2) {
|
||||||
|
c1 = c1 + c2;
|
||||||
|
return c1;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace router
|
} // namespace router
|
||||||
} // namespace pfaedle
|
} // namespace pfaedle
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue