main.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. * @file main.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 <boost/timer.hpp>
  26. #include <common/RootCoordinator.hpp>
  27. #include <common/scheduler/VectorScheduler.hpp>
  28. #include <common/scheduler/HeapScheduler.hpp>
  29. #include <tests/mixed_tests.hpp>
  30. void run_flat_with_heap()
  31. {
  32. paradevs::common::RootCoordinator <
  33. paradevs::MyTime, paradevs::pdevs::Coordinator <
  34. paradevs::MyTime,
  35. paradevs::common::scheduler::HeapScheduler < paradevs::MyTime >,
  36. paradevs::LinearGraphManager >
  37. > rc(0, 500, "root", paradevs::pdevs::Parameters());
  38. paradevs::common::Trace < paradevs::MyTime >::trace().clear();
  39. rc.run();
  40. }
  41. void run_flat_with_vector()
  42. {
  43. paradevs::common::RootCoordinator <
  44. paradevs::MyTime, paradevs::pdevs::Coordinator <
  45. paradevs::MyTime,
  46. paradevs::common::scheduler::VectorScheduler < paradevs::MyTime >,
  47. paradevs::LinearGraphManager >
  48. > rc(0, 500, "root", paradevs::pdevs::Parameters());
  49. paradevs::common::Trace < paradevs::MyTime >::trace().clear();
  50. rc.run();
  51. }
  52. void run_hierarchic_with_heap()
  53. {
  54. paradevs::common::RootCoordinator <
  55. paradevs::MyTime, paradevs::pdevs::Coordinator <
  56. paradevs::MyTime,
  57. paradevs::common::scheduler::VectorScheduler < paradevs::MyTime >,
  58. paradevs::Root2GraphManager >
  59. > rc(0, 500, "root", paradevs::pdevs::Parameters());
  60. paradevs::common::Trace < paradevs::MyTime >::trace().clear();
  61. rc.run();
  62. }
  63. void run_hierarchic_with_vector()
  64. {
  65. paradevs::common::RootCoordinator <
  66. paradevs::MyTime, paradevs::pdevs::Coordinator <
  67. paradevs::MyTime,
  68. paradevs::common::scheduler::VectorScheduler < paradevs::MyTime >,
  69. paradevs::Root3GraphManager >
  70. > rc(0, 500, "root", paradevs::pdevs::Parameters());
  71. paradevs::common::Trace < paradevs::MyTime >::trace().clear();
  72. rc.run();
  73. }
  74. int main()
  75. {
  76. boost::timer t;
  77. std::cout << "run_flat_with_heap ..." << std::endl;
  78. run_flat_with_heap();
  79. double t1 = t.elapsed();
  80. std::cout << "... OK -> " << t1 << std::endl;
  81. std::cout << "run_flat_with_vector ..." << std::endl;
  82. run_flat_with_vector();
  83. double t2 = t.elapsed();
  84. std::cout << "... OK -> " << (t2 - t1) << std::endl;
  85. std::cout << "run_hierarchic_with_heap ..." << std::endl;
  86. run_hierarchic_with_heap();
  87. double t3 = t.elapsed();
  88. std::cout << "... OK -> " << (t3 - t2) << std::endl;
  89. std::cout << "run_hierarchic_with_vector ..." << std::endl;
  90. run_hierarchic_with_vector();
  91. double t4 = t.elapsed();
  92. std::cout << "... OK -> " << (t4 - t3) << std::endl;
  93. return 0;
  94. }