diff --git a/src/graph/graph.cc b/src/graph/graph.cc index 2c03790..3259c44 100644 --- a/src/graph/graph.cc +++ b/src/graph/graph.cc @@ -6,7 +6,7 @@ #include "svg.h" -void Graph::svg_demo(Analyse::track_data_t track_data) { +std::string Graph::svg_demo(Analyse::track_data_t track_data) { // for (uint32_t i = 0; i < track_data.size(); ++i) { // @@ -154,6 +154,6 @@ void Graph::svg_demo(Analyse::track_data_t track_data) { } } - std::cout << svg.dump() << std::endl; + return svg.dump(); } diff --git a/src/graph/graph.h b/src/graph/graph.h index ddec392..f28e0e5 100644 --- a/src/graph/graph.h +++ b/src/graph/graph.h @@ -51,6 +51,6 @@ public: uint64_t LINE_OFFSET = 2; - void svg_demo(Analyse::track_data_t track_data); + std::string svg_demo(Analyse::track_data_t track_data); }; diff --git a/src/main.cc b/src/main.cc index 11b85ff..c2a9e0b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -13,10 +13,12 @@ #include #include #include +#include +//int main(int argc, char *argv[]) { int main() { - BasicRanges::build(); +// BasicRanges::build(); // AllCases::build(); @@ -42,7 +44,7 @@ int main() { // sleep(3); // std::cout << "start benchmark" << std::endl; - auto start_time = clock(); +// auto start_time = clock(); // auto fc = FastCal(RawCode::from_common_code("1a9bf0c")); @@ -60,11 +62,34 @@ int main() { // auto a = Analyse(RawCode::from_common_code("1a9bf0c")); // auto a = Analyse(RawCode::from_common_code("4fea134")); // auto a = Analyse(RawCode::from_common_code("A5D3AF")); - auto a = Analyse(RawCode::from_common_code("1FA6F80")); +// auto a = Analyse(RawCode::from_common_code("1FA6F80")); +// auto a = Analyse(RawCode::from_common_code("0F5747")); + +// if (argc < 2) { +// std::cout << "without input code" << std::endl; +// } +// auto a = Analyse(RawCode::from_common_code(argv[1])); + + + std::string input; + std::cout << "Please give a common code: "; + std::cin >> input; + + auto common_code = CommonCode::from_string(input); + + std::cout << ShortCode::from_common_code(common_code).to_string() << " -> "; + + auto start_time = clock(); + + auto a = Analyse(RawCode::from_common_code(common_code)); + // a.build(); auto ret = a.build_until([](uint64_t code) { return ((code >> (3 * 0xD)) & 0b111) == B_2x2; }); + std::cout << ret.size() << std::endl; + + std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; // std::cout << "analyse complete" << std::endl; // for (const auto &r : ret) { @@ -80,7 +105,15 @@ int main() { // std::cout << "backtrack complete" << std::endl; auto g = Graph(); - g.svg_demo(svg_ret); + auto svg_data = g.svg_demo(svg_ret); + + + std::ofstream output; + output.open(common_code.to_string(true) + ".svg"); + output << svg_data << std::endl; + output.close(); + +// std::cout << svg_data << std::endl; // auto start_time = clock(); @@ -126,11 +159,12 @@ int main() { // std::cerr << (clock() - start_time) / CLOCKS_PER_SEC << "s" << std::endl; // std::cerr << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl; - std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; +// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; // std::cout << "complete benchmark" << std::endl; -// pause(); + std::cerr << "Press CTRL-C for exit..."; + pause(); return 0; }