main.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @file tests/multithreading/simple/main.cpp
  3. * @author The ARTIS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * ARTIS - the multimodeling and simulation environment
  8. * This file is a part of the ARTIS environment
  9. *
  10. * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #include <artis-star/common/RootCoordinator.hpp>
  26. #include <tests/multithreading/simple/graph_manager.hpp>
  27. #include <tests/multithreading/simple/models.hpp>
  28. #include <chrono>
  29. #include <iostream>
  30. using namespace artis::common;
  31. using namespace std::chrono;
  32. using namespace artis::tests::multithreading::simple;
  33. void simple_monothreading() {
  34. GeneratorParameters parameters = {10, 2, 5, 763752};
  35. artis::common::context::Context<artis::common::DoubleTime> context(0, 1000);
  36. artis::common::RootCoordinator<
  37. DoubleTime, artis::pdevs::Coordinator<
  38. DoubleTime,
  39. SimpleGraphManager,
  40. GeneratorParameters,
  41. NoParameters>
  42. > rc(context, "root", parameters, NoParameters());
  43. steady_clock::time_point t1 = steady_clock::now();
  44. rc.run(context);
  45. steady_clock::time_point t2 = steady_clock::now();
  46. duration<double> time_span = duration_cast<duration<double> >(t2 - t1);
  47. std::cout << "Time = " << time_span.count() << std::endl;
  48. }
  49. void simple_multithreading() {
  50. GeneratorParameters parameters = {10, 2, 5, 763752};
  51. artis::common::context::Context<artis::common::DoubleTime> context(0, 1000);
  52. artis::common::RootCoordinator<
  53. DoubleTime, artis::pdevs::multithreading::Coordinator<
  54. DoubleTime,
  55. SimpleGraphManager,
  56. GeneratorParameters,
  57. NoParameters>
  58. > rc(context, "root", parameters, NoParameters());
  59. steady_clock::time_point t1 = steady_clock::now();
  60. rc.run(context);
  61. steady_clock::time_point t2 = steady_clock::now();
  62. duration<double> time_span = duration_cast<duration<double> >(t2 - t1);
  63. std::cout << "Time = " << time_span.count() << std::endl;
  64. }
  65. int main() {
  66. // simple_monothreading();
  67. simple_multithreading();
  68. return 0;
  69. }