tests.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /**
  2. * @file tests/multithreading/tests.cpp
  3. * @author The PARADEVS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * PARADEVS - the multimodeling and simulation environment
  8. * This file is a part of the PARADEVS environment
  9. *
  10. * Copyright (C) 2013-2016 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 <tests/multithreading/graph_manager.hpp>
  26. #include <tests/pdevs/graph_manager.hpp>
  27. #include <paradevs/common/RootCoordinator.hpp>
  28. #include <chrono>
  29. #define CATCH_CONFIG_MAIN
  30. #include <tests/catch.hpp>
  31. using namespace paradevs::tests::pdevs;
  32. using namespace paradevs::tests::multithreading;
  33. using namespace paradevs::common;
  34. using namespace std::chrono;
  35. TEST_CASE("pdevs/multithreading/hierachical", "run")
  36. {
  37. steady_clock::time_point t1 = steady_clock::now();
  38. paradevs::common::RootCoordinator <
  39. DoubleTime, paradevs::pdevs::multithreading::Coordinator <
  40. DoubleTime,
  41. paradevs::tests::multithreading::RootGraphManager >
  42. > rc(0, 100, "root", paradevs::common::NoParameters(),
  43. paradevs::common::NoParameters());
  44. rc.run();
  45. steady_clock::time_point t2 = steady_clock::now();
  46. duration < double > time_span = duration_cast <
  47. duration < double > >(t2 - t1);
  48. std::cout << "multithreading/dependant -> " << time_span.count()
  49. << std::endl;
  50. }
  51. TEST_CASE("pdevs/classic/hierachical", "run")
  52. {
  53. steady_clock::time_point t1 = steady_clock::now();
  54. paradevs::common::RootCoordinator <
  55. DoubleTime, paradevs::pdevs::Coordinator <
  56. DoubleTime,
  57. paradevs::tests::pdevs::RootGraphManager >
  58. > rc(0, 100, "root", paradevs::common::NoParameters(),
  59. paradevs::common::NoParameters());
  60. rc.run();
  61. steady_clock::time_point t2 = steady_clock::now();
  62. duration < double > time_span = duration_cast <
  63. duration < double > >(t2 - t1);
  64. std::cout << "classic/dependant -> " << time_span.count() << std::endl;
  65. }
  66. TEST_CASE("pdevs/multithreading/independant", "run")
  67. {
  68. steady_clock::time_point t1 = steady_clock::now();
  69. paradevs::common::RootCoordinator <
  70. DoubleTime, paradevs::pdevs::multithreading::Coordinator <
  71. DoubleTime,
  72. paradevs::tests::multithreading::Root2GraphManager >
  73. > rc(0, 100, "root", paradevs::common::NoParameters(),
  74. paradevs::common::NoParameters());
  75. rc.run();
  76. steady_clock::time_point t2 = steady_clock::now();
  77. duration < double > time_span = duration_cast <
  78. duration < double > >(t2 - t1);
  79. std::cout << "multithreading/independant -> " << time_span.count()
  80. << std::endl;
  81. }
  82. TEST_CASE("pdevs/classic/independant", "run")
  83. {
  84. steady_clock::time_point t1 = steady_clock::now();
  85. paradevs::common::RootCoordinator <
  86. DoubleTime, paradevs::pdevs::Coordinator <
  87. DoubleTime,
  88. paradevs::tests::multithreading::Root3GraphManager >
  89. > rc(0, 100, "root", paradevs::common::NoParameters(),
  90. paradevs::common::NoParameters());
  91. rc.run();
  92. steady_clock::time_point t2 = steady_clock::now();
  93. duration < double > time_span = duration_cast <
  94. duration < double > >(t2 - t1);
  95. std::cout << "classic/independant -> " << time_span.count() << std::endl;
  96. }