main.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. template < int size >
  31. void run_flat_with_heap()
  32. {
  33. boost::timer t;
  34. std::cout << "run_flat_with_heap [" << size << "] ..." << std::endl;
  35. paradevs::common::RootCoordinator <
  36. paradevs::MyTime, paradevs::pdevs::Coordinator <
  37. paradevs::MyTime,
  38. paradevs::common::scheduler::HeapScheduler < paradevs::MyTime >,
  39. paradevs::LinearGraphManager < size > >
  40. > rc(0, 100, "root", paradevs::pdevs::Parameters());
  41. paradevs::common::Trace < paradevs::MyTime >::trace().clear();
  42. rc.run();
  43. std::cout << "... OK -> " << t.elapsed() << std::endl;
  44. }
  45. template < int size >
  46. void run_flat_with_vector()
  47. {
  48. boost::timer t;
  49. std::cout << "run_flat_with_vector [" << size << "] ..." << std::endl;
  50. paradevs::common::RootCoordinator <
  51. paradevs::MyTime, paradevs::pdevs::Coordinator <
  52. paradevs::MyTime,
  53. paradevs::common::scheduler::VectorScheduler < paradevs::MyTime >,
  54. paradevs::LinearGraphManager < size > >
  55. > rc(0, 100, "root", paradevs::pdevs::Parameters());
  56. paradevs::common::Trace < paradevs::MyTime >::trace().clear();
  57. rc.run();
  58. std::cout << "... OK -> " << t.elapsed() << std::endl;
  59. }
  60. void run_hierarchic_with_heap()
  61. {
  62. paradevs::common::RootCoordinator <
  63. paradevs::MyTime, paradevs::pdevs::Coordinator <
  64. paradevs::MyTime,
  65. paradevs::common::scheduler::HeapScheduler < paradevs::MyTime >,
  66. paradevs::Root2GraphManager >
  67. > rc(0, 100, "root", paradevs::pdevs::Parameters());
  68. paradevs::common::Trace < paradevs::MyTime >::trace().clear();
  69. rc.run();
  70. }
  71. void run_hierarchic_with_vector()
  72. {
  73. paradevs::common::RootCoordinator <
  74. paradevs::MyTime, paradevs::pdevs::Coordinator <
  75. paradevs::MyTime,
  76. paradevs::common::scheduler::VectorScheduler < paradevs::MyTime >,
  77. paradevs::Root3GraphManager >
  78. > rc(0, 100, "root", paradevs::pdevs::Parameters());
  79. paradevs::common::Trace < paradevs::MyTime >::trace().clear();
  80. rc.run();
  81. }
  82. int main()
  83. {
  84. boost::timer t;
  85. srand(108364);
  86. run_flat_with_heap < 10 >();
  87. run_flat_with_heap < 20 >();
  88. run_flat_with_heap < 30 >();
  89. run_flat_with_heap < 40 >();
  90. run_flat_with_heap < 50 >();
  91. run_flat_with_heap < 60 >();
  92. run_flat_with_heap < 70 >();
  93. run_flat_with_heap < 80 >();
  94. run_flat_with_heap < 90 >();
  95. run_flat_with_heap < 100 >();
  96. run_flat_with_heap < 200 >();
  97. run_flat_with_vector < 10 >();
  98. run_flat_with_vector < 20 >();
  99. run_flat_with_vector < 30 >();
  100. run_flat_with_vector < 40 >();
  101. run_flat_with_vector < 50 >();
  102. run_flat_with_vector < 60 >();
  103. run_flat_with_vector < 70 >();
  104. run_flat_with_vector < 80 >();
  105. run_flat_with_vector < 90 >();
  106. run_flat_with_vector < 100 >();
  107. run_flat_with_vector < 200 >();
  108. double t2 = t.elapsed();
  109. std::cout << "run_hierarchic_with_heap ..." << std::endl;
  110. run_hierarchic_with_heap();
  111. double t3 = t.elapsed();
  112. std::cout << "... OK -> " << (t3 - t2) << std::endl;
  113. std::cout << "run_hierarchic_with_vector ..." << std::endl;
  114. run_hierarchic_with_vector();
  115. double t4 = t.elapsed();
  116. std::cout << "... OK -> " << (t4 - t3) << std::endl;
  117. return 0;
  118. }