main.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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-2022 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 <artis-star/kernel/pdevs/multithreading/Coordinator.hpp>
  27. #include <tests/multithreading/simple/graph_manager.hpp>
  28. #include <tests/multithreading/simple/models.hpp>
  29. #include <chrono>
  30. #include <iostream>
  31. using namespace artis::common;
  32. using namespace std::chrono;
  33. using namespace artis::tests::multithreading::simple;
  34. //void simple_monothreading()
  35. //{
  36. // GeneratorParameters parameters = {10, 2, 5, 763752};
  37. // artis::common::context::Context<artis::common::DoubleTime> context(0, 200000);
  38. // artis::common::RootCoordinator<
  39. // DoubleTime, artis::pdevs::Coordinator<
  40. // DoubleTime,
  41. // SimpleGraphManager,
  42. // GeneratorParameters,
  43. // NoParameters>
  44. // > rc(context, "root", parameters, NoParameters());
  45. //
  46. // steady_clock::time_point t1 = steady_clock::now();
  47. //
  48. // rc.run(context);
  49. //
  50. // steady_clock::time_point t2 = steady_clock::now();
  51. //
  52. // duration<double> time_span = duration_cast<duration<double> >(t2 - t1);
  53. //
  54. // std::cout << "Time = " << time_span.count() << std::endl;
  55. //}
  56. void simple_multithreading()
  57. {
  58. GeneratorParameters parameters = {10, 2, 5, 763752};
  59. artis::common::context::Context<artis::common::DoubleTime> context(0, 200000);
  60. artis::common::RootCoordinator<
  61. DoubleTime, artis::pdevs::multithreading::Coordinator<
  62. DoubleTime,
  63. SimpleGraphManager,
  64. GeneratorParameters,
  65. NoParameters>
  66. > rc(context, "root", parameters, NoParameters());
  67. steady_clock::time_point t1 = steady_clock::now();
  68. rc.run(context);
  69. steady_clock::time_point t2 = steady_clock::now();
  70. duration<double> time_span = duration_cast<duration<double> >(t2 - t1);
  71. std::cout << "Time = " << time_span.count() << std::endl;
  72. }
  73. int main()
  74. {
  75. // simple_monothreading();
  76. simple_multithreading();
  77. return 0;
  78. }