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-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 <artis-star/kernel/pdevs/multithreading/RootCoordinator.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. steady_clock::time_point t1 = steady_clock::now();
  46. rc.run(context);
  47. steady_clock::time_point t2 = steady_clock::now();
  48. duration<double> time_span = duration_cast<duration<double> >(t2 - t1);
  49. std::cout << "Time = " << time_span.count() << std::endl;
  50. }
  51. //void simple_multithreading()
  52. //{
  53. // GeneratorParameters parameters = {10, 2, 5, 763752};
  54. // artis::common::context::Context<artis::common::DoubleTime> context(0, 200000);
  55. // artis::common::RootCoordinator<
  56. // DoubleTime, artis::pdevs::multithreading::Coordinator<
  57. // DoubleTime,
  58. // SimpleGraphManager,
  59. // GeneratorParameters,
  60. // NoParameters>
  61. // > rc(context, "root", parameters, NoParameters());
  62. //
  63. // steady_clock::time_point t1 = steady_clock::now();
  64. //
  65. // rc.run(context);
  66. //
  67. // steady_clock::time_point t2 = steady_clock::now();
  68. //
  69. // duration<double> time_span = duration_cast<duration<double> >(t2 - t1);
  70. //
  71. // std::cout << "Time = " << time_span.count() << std::endl;
  72. //}
  73. int main()
  74. {
  75. simple_monothreading();
  76. // simple_multithreading();
  77. return 0;
  78. }