main.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /**
  2. * @file app/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 <kernel/pdevs/Coordinator.hpp>
  30. #include <tests/mixed/models.hpp>
  31. #include <tests/mixed/graph_manager.hpp>
  32. using namespace paradevs::tests::mixed;
  33. template < int size >
  34. void run_flat_with_heap()
  35. {
  36. boost::timer t;
  37. std::cout << "run_flat_with_heap [" << size << "] ..." << std::endl;
  38. paradevs::common::RootCoordinator <
  39. paradevs::common::DoubleTime, paradevs::pdevs::Coordinator <
  40. paradevs::common::DoubleTime,
  41. paradevs::common::scheduler::HeapScheduler <
  42. paradevs::common::DoubleTime, SchedulerHandle >,
  43. SchedulerHandle,
  44. LinearGraphManager < size, SchedulerHandle > >
  45. > rc(0, 100, "root", paradevs::common::NoParameters(),
  46. paradevs::common::NoParameters());
  47. paradevs::common::Trace < paradevs::common::DoubleTime >::trace().clear();
  48. rc.run();
  49. std::cout << "... OK -> " << t.elapsed() << std::endl;
  50. }
  51. template < int size >
  52. void run_flat_with_vector()
  53. {
  54. boost::timer t;
  55. std::cout << "run_flat_with_vector [" << size << "] ..." << std::endl;
  56. paradevs::common::RootCoordinator <
  57. paradevs::common::DoubleTime, paradevs::pdevs::Coordinator <
  58. paradevs::common::DoubleTime,
  59. paradevs::common::scheduler::VectorScheduler <
  60. paradevs::common::DoubleTime >,
  61. paradevs::common::scheduler::NoSchedulerHandle,
  62. LinearGraphManager <
  63. size, paradevs::common::scheduler::NoSchedulerHandle > >
  64. > rc(0, 100, "root", paradevs::common::NoParameters(),
  65. paradevs::common::NoParameters());
  66. paradevs::common::Trace < paradevs::common::DoubleTime >::trace().clear();
  67. rc.run();
  68. std::cout << "... OK -> " << t.elapsed() << std::endl;
  69. }
  70. void run_hierarchic_with_heap()
  71. {
  72. paradevs::common::RootCoordinator <
  73. paradevs::common::DoubleTime, paradevs::pdevs::Coordinator <
  74. paradevs::common::DoubleTime,
  75. paradevs::common::scheduler::HeapScheduler <
  76. paradevs::common::DoubleTime, SchedulerHandle >,
  77. SchedulerHandle,
  78. Root2GraphManager >
  79. > rc(0, 100, "root", paradevs::common::NoParameters(),
  80. paradevs::common::NoParameters());
  81. paradevs::common::Trace < paradevs::common::DoubleTime >::trace().clear();
  82. rc.run();
  83. }
  84. void run_hierarchic_with_vector()
  85. {
  86. paradevs::common::RootCoordinator <
  87. paradevs::common::DoubleTime, paradevs::pdevs::Coordinator <
  88. paradevs::common::DoubleTime,
  89. paradevs::common::scheduler::VectorScheduler <
  90. paradevs::common::DoubleTime >,
  91. paradevs::common::scheduler::NoSchedulerHandle,
  92. Root3GraphManager >
  93. > rc(0, 100, "root", paradevs::common::NoParameters(),
  94. paradevs::common::NoParameters());
  95. paradevs::common::Trace < paradevs::common::DoubleTime >::trace().clear();
  96. rc.run();
  97. }
  98. int main()
  99. {
  100. boost::timer t;
  101. srand(108364);
  102. run_flat_with_heap < 10 >();
  103. run_flat_with_heap < 20 >();
  104. run_flat_with_heap < 30 >();
  105. run_flat_with_heap < 40 >();
  106. run_flat_with_heap < 50 >();
  107. run_flat_with_heap < 60 >();
  108. run_flat_with_heap < 70 >();
  109. run_flat_with_heap < 80 >();
  110. run_flat_with_heap < 90 >();
  111. run_flat_with_heap < 100 >();
  112. run_flat_with_heap < 200 >();
  113. run_flat_with_vector < 10 >();
  114. run_flat_with_vector < 20 >();
  115. run_flat_with_vector < 30 >();
  116. run_flat_with_vector < 40 >();
  117. run_flat_with_vector < 50 >();
  118. run_flat_with_vector < 60 >();
  119. run_flat_with_vector < 70 >();
  120. run_flat_with_vector < 80 >();
  121. run_flat_with_vector < 90 >();
  122. run_flat_with_vector < 100 >();
  123. run_flat_with_vector < 200 >();
  124. double t2 = t.elapsed();
  125. std::cout << "run_hierarchic_with_heap ..." << std::endl;
  126. run_hierarchic_with_heap();
  127. double t3 = t.elapsed();
  128. std::cout << "... OK -> " << (t3 - t2) << std::endl;
  129. std::cout << "run_hierarchic_with_vector ..." << std::endl;
  130. run_hierarchic_with_vector();
  131. double t4 = t.elapsed();
  132. std::cout << "... OK -> " << (t4 - t3) << std::endl;
  133. return 0;
  134. }