main.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. {
  35. GeneratorParameters parameters = {10, 2, 5, 763752};
  36. artis::common::context::Context<artis::common::DoubleTime> context(0, 1000);
  37. artis::common::RootCoordinator<
  38. DoubleTime, artis::pdevs::Coordinator<
  39. DoubleTime,
  40. SimpleGraphManager,
  41. GeneratorParameters,
  42. NoParameters>
  43. > rc(context, "root", parameters, NoParameters());
  44. steady_clock::time_point t1 = steady_clock::now();
  45. rc.run(context);
  46. steady_clock::time_point t2 = steady_clock::now();
  47. duration<double> time_span = duration_cast<duration<double> >(t2 - t1);
  48. std::cout << "Time = " << time_span.count() << std::endl;
  49. }
  50. void simple_multithreading()
  51. {
  52. GeneratorParameters parameters = {10, 2, 5, 763752};
  53. artis::common::context::Context<artis::common::DoubleTime> context(0, 1000);
  54. artis::common::RootCoordinator<
  55. DoubleTime, artis::pdevs::multithreading::Coordinator<
  56. DoubleTime,
  57. SimpleGraphManager,
  58. GeneratorParameters,
  59. NoParameters>
  60. > rc(context, "root", parameters, NoParameters());
  61. steady_clock::time_point t1 = steady_clock::now();
  62. rc.run(context);
  63. steady_clock::time_point t2 = steady_clock::now();
  64. duration<double> time_span = duration_cast<duration<double> >(t2 - t1);
  65. std::cout << "Time = " << time_span.count() << std::endl;
  66. }
  67. int main()
  68. {
  69. // simple_monothreading();
  70. simple_multithreading();
  71. return 0;
  72. }