tests.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 ULCO http://www.univ-litoral.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::common::scheduler::HeapScheduler <
  42. DoubleTime, SchedulerHandle >,
  43. SchedulerHandle,
  44. paradevs::tests::multithreading::RootGraphManager >
  45. > rc(0, 100, "root", paradevs::common::NoParameters(),
  46. paradevs::common::NoParameters());
  47. rc.run();
  48. steady_clock::time_point t2 = steady_clock::now();
  49. duration < double > time_span = duration_cast <
  50. duration < double > >(t2 - t1);
  51. std::cout << "multithreading/dependant -> " << time_span.count()
  52. << std::endl;
  53. }
  54. TEST_CASE("pdevs/classic/hierachical", "run")
  55. {
  56. steady_clock::time_point t1 = steady_clock::now();
  57. paradevs::common::RootCoordinator <
  58. DoubleTime, paradevs::pdevs::Coordinator <
  59. DoubleTime,
  60. paradevs::common::scheduler::HeapScheduler <
  61. DoubleTime, SchedulerHandle >,
  62. SchedulerHandle,
  63. paradevs::tests::pdevs::RootGraphManager >
  64. > rc(0, 100, "root", paradevs::common::NoParameters(),
  65. paradevs::common::NoParameters());
  66. rc.run();
  67. steady_clock::time_point t2 = steady_clock::now();
  68. duration < double > time_span = duration_cast <
  69. duration < double > >(t2 - t1);
  70. std::cout << "classic/dependant -> " << time_span.count() << std::endl;
  71. }
  72. TEST_CASE("pdevs/multithreading/independant", "run")
  73. {
  74. steady_clock::time_point t1 = steady_clock::now();
  75. paradevs::common::RootCoordinator <
  76. DoubleTime, paradevs::pdevs::multithreading::Coordinator <
  77. DoubleTime,
  78. paradevs::common::scheduler::HeapScheduler <
  79. DoubleTime, SchedulerHandle >,
  80. SchedulerHandle,
  81. paradevs::tests::multithreading::Root2GraphManager >
  82. > rc(0, 100, "root", paradevs::common::NoParameters(),
  83. paradevs::common::NoParameters());
  84. rc.run();
  85. steady_clock::time_point t2 = steady_clock::now();
  86. duration < double > time_span = duration_cast <
  87. duration < double > >(t2 - t1);
  88. std::cout << "multithreading/independant -> " << time_span.count()
  89. << std::endl;
  90. }
  91. TEST_CASE("pdevs/classic/independant", "run")
  92. {
  93. steady_clock::time_point t1 = steady_clock::now();
  94. paradevs::common::RootCoordinator <
  95. DoubleTime, paradevs::pdevs::Coordinator <
  96. DoubleTime,
  97. paradevs::common::scheduler::HeapScheduler <
  98. DoubleTime, SchedulerHandle >,
  99. SchedulerHandle,
  100. paradevs::tests::multithreading::Root3GraphManager >
  101. > rc(0, 100, "root", paradevs::common::NoParameters(),
  102. paradevs::common::NoParameters());
  103. rc.run();
  104. steady_clock::time_point t2 = steady_clock::now();
  105. duration < double > time_span = duration_cast <
  106. duration < double > >(t2 - t1);
  107. std::cout << "classic/independant -> " << time_span.count() << std::endl;
  108. }