PerformanceTests.cc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * Copyright (c) 2013 committers of YAKINDU and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * committers of YAKINDU - initial API and implementation
  10. */
  11. #include <string>
  12. #include "gtest/gtest.h"
  13. #include "PerformanceTest.h"
  14. TEST(StatemachineTest, test_100_000) {
  15. PerformanceTest handle;
  16. performanceTest_init(&handle);
  17. performanceTest_enter(&handle);
  18. EXPECT_TRUE(performanceTest_isActive(&handle, PerformanceTest_mr_A));
  19. while (performanceTestIface_get_c(&handle)< 100000) {
  20. if (performanceTest_isActive(&handle, PerformanceTest_mr_A)) {
  21. performanceTestIface_raise_e1(&handle);;
  22. }
  23. else {
  24. if (performanceTestIface_get_c(&handle)%2== 0) {
  25. performanceTestIface_raise_e2(&handle);;
  26. }
  27. else {
  28. performanceTestIface_raise_e3(&handle);;
  29. }
  30. ;
  31. }
  32. performanceTest_runCycle(&handle);
  33. }
  34. EXPECT_TRUE(performanceTestIface_get_a(&handle)> 2);
  35. }
  36. TEST(StatemachineTest, test_1_000_000) {
  37. PerformanceTest handle;
  38. performanceTest_init(&handle);
  39. performanceTest_enter(&handle);
  40. EXPECT_TRUE(performanceTest_isActive(&handle, PerformanceTest_mr_A));
  41. while (performanceTestIface_get_c(&handle)< 1000000) {
  42. if (performanceTest_isActive(&handle, PerformanceTest_mr_A)) {
  43. performanceTestIface_raise_e1(&handle);;
  44. }
  45. else {
  46. if (performanceTestIface_get_c(&handle)%2== 0) {
  47. performanceTestIface_raise_e2(&handle);;
  48. }
  49. else {
  50. performanceTestIface_raise_e3(&handle);;
  51. }
  52. ;
  53. }
  54. performanceTest_runCycle(&handle);
  55. }
  56. EXPECT_TRUE(performanceTestIface_get_a(&handle)> 2);
  57. }
  58. TEST(StatemachineTest, test_10_000_000) {
  59. PerformanceTest handle;
  60. performanceTest_init(&handle);
  61. performanceTest_enter(&handle);
  62. EXPECT_TRUE(performanceTest_isActive(&handle, PerformanceTest_mr_A));
  63. while (performanceTestIface_get_c(&handle)< 10000000) {
  64. if (performanceTest_isActive(&handle, PerformanceTest_mr_A)) {
  65. performanceTestIface_raise_e1(&handle);;
  66. }
  67. else {
  68. if (performanceTestIface_get_c(&handle)%2== 0) {
  69. performanceTestIface_raise_e2(&handle);;
  70. }
  71. else {
  72. performanceTestIface_raise_e3(&handle);;
  73. }
  74. ;
  75. }
  76. performanceTest_runCycle(&handle);
  77. }
  78. EXPECT_TRUE(performanceTestIface_get_a(&handle)> 2);
  79. }