tests.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @file tests/multithreading/lifegame/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/lifegame/graph_manager.hpp>
  26. #include <paradevs/common/RootCoordinator.hpp>
  27. #include <chrono>
  28. #define CATCH_CONFIG_MAIN
  29. #include <tests/catch.hpp>
  30. using namespace paradevs::tests::pdevs;
  31. using namespace paradevs::tests::multithreading;
  32. using namespace paradevs::common;
  33. using namespace std::chrono;
  34. TEST_CASE("pdevs/multithreading/lifegame", "run")
  35. {
  36. steady_clock::time_point t1 = steady_clock::now();
  37. paradevs::common::RootCoordinator <
  38. DoubleTime, paradevs::pdevs::multithreading::Coordinator <
  39. DoubleTime,
  40. paradevs::common::scheduler::HeapScheduler <
  41. DoubleTime, SchedulerHandle >,
  42. SchedulerHandle,
  43. paradevs::tests::multithreading::RootGraphManager >
  44. > rc(0, 100, "root", paradevs::common::NoParameters(),
  45. paradevs::common::NoParameters());
  46. rc.run();
  47. steady_clock::time_point t2 = steady_clock::now();
  48. duration < double > time_span = duration_cast <
  49. duration < double > >(t2 - t1);
  50. std::cout << "multithreading/dependant -> " << time_span.count()
  51. << std::endl;
  52. }
  53. TEST_CASE("pdevs/mono/lifegame", "run")
  54. {
  55. steady_clock::time_point t1 = steady_clock::now();
  56. paradevs::common::RootCoordinator <
  57. DoubleTime, paradevs::pdevs::Coordinator <
  58. DoubleTime,
  59. paradevs::common::scheduler::HeapScheduler <
  60. DoubleTime, SchedulerHandle >,
  61. SchedulerHandle,
  62. paradevs::tests::pdevs::RootGraphManager >
  63. > rc(0, 100, "root", paradevs::common::NoParameters(),
  64. paradevs::common::NoParameters());
  65. rc.run();
  66. steady_clock::time_point t2 = steady_clock::now();
  67. duration < double > time_span = duration_cast <
  68. duration < double > >(t2 - t1);
  69. std::cout << "classic/dependant -> " << time_span.count() << std::endl;
  70. }