PageRenderTime 46ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/src/tests/gov/nasa/jpf/symbc/strings/performance/Performance01.java

https://bitbucket.org/MateusAraujoBorges/jpf-symbc-gsoc
Java | 150 lines | 128 code | 5 blank | 17 comment | 34 complexity | 78326a6192e4db995ca0089660171493 MD5 | raw file
  1. package gov.nasa.jpf.symbc.strings.performance;
  2. public class Performance01 {
  3. //MAX_LENGTH = 5 for all tests
  4. private static final int MAX_LENGTH = 10;
  5. /*
  6. * Multiple symbolic string performance test
  7. *
  8. * There is two variables to play with here:
  9. * - The amount of symbolic string variables, set by the different testX methods
  10. * - The maximum length of each symbolic string variable set by MAX_LENGTH
  11. */
  12. public static void main (String [] args) {
  13. test2 ("dcba", "a","b");
  14. }
  15. public static void test (String a, String b) {
  16. int i = 0;
  17. if (a.endsWith("a")) {
  18. System.out.println("Step 1");
  19. i++;
  20. }
  21. if (b.endsWith("b")) {
  22. System.out.println("Step 2");
  23. i++;
  24. }
  25. if (a.startsWith(b)) {
  26. System.out.println("Step 3");
  27. i++;
  28. }
  29. if (!a.equals(b)) {
  30. System.out.println("Step 4");
  31. i++;
  32. }
  33. if (a.trim().contains(b)) {
  34. System.out.println("Step 5");
  35. i++;
  36. }
  37. /*if (i == 5) {
  38. throw new RuntimeException ("look at this");
  39. }*/
  40. }
  41. public static void test2 (String a, String b, String c) {
  42. int i = 0;
  43. if (a.length () < MAX_LENGTH && b.length() < MAX_LENGTH && c.length() < MAX_LENGTH) {
  44. if (a.endsWith("a")) {
  45. System.out.println("Step 1");
  46. i++;
  47. }
  48. if (b.endsWith("b")) {
  49. System.out.println("Step 2");
  50. i++;
  51. }
  52. if (c.endsWith("c")) {
  53. System.out.println("Step 3");
  54. i++;
  55. }
  56. if (a.startsWith(b)) {
  57. System.out.println("Step 4");
  58. i++;
  59. }
  60. if (b.startsWith(c)) {
  61. System.out.println("Step 5");
  62. i++;
  63. }
  64. if (!a.equals(b)) {
  65. System.out.println("Step 6");
  66. i++;
  67. }
  68. if (!b.equals(c)) {
  69. System.out.println("Step 7");
  70. i++;
  71. }
  72. if (a.trim().contains(b)) {
  73. System.out.println("Step 8");
  74. i++;
  75. }
  76. if (b.trim().contains(c)) {
  77. System.out.println("Step 9");
  78. i++;
  79. }
  80. /*if (i == 9) {
  81. throw new RuntimeException ("look at this");
  82. }*/
  83. }
  84. }
  85. public static void test3 (String a, String b, String c, String d) {
  86. int i = 0;
  87. if (a.length () < MAX_LENGTH && b.length() < MAX_LENGTH && c.length() < MAX_LENGTH && d.length() < MAX_LENGTH) {
  88. if (a.endsWith("a")) {
  89. System.out.println("Step 1");
  90. i++;
  91. }
  92. if (b.endsWith("b")) {
  93. System.out.println("Step 2");
  94. i++;
  95. }
  96. if (c.endsWith("c")) {
  97. System.out.println("Step 3");
  98. i++;
  99. }
  100. if (d.endsWith("d")) {
  101. System.out.println("Step 4");
  102. i++;
  103. }
  104. if (a.startsWith(b)) {
  105. System.out.println("Step 5");
  106. i++;
  107. }
  108. if (b.startsWith(c)) {
  109. System.out.println("Step 6");
  110. i++;
  111. }
  112. if (c.startsWith(d)) {
  113. System.out.println("Step 7");
  114. i++;
  115. }
  116. if (!a.equals(b)) {
  117. System.out.println("Step 8");
  118. i++;
  119. }
  120. if (!b.equals(c)) {
  121. System.out.println("Step 9");
  122. i++;
  123. }
  124. if (!c.equals(d)) {
  125. System.out.println("Step 10");
  126. i++;
  127. }
  128. if (a.trim().contains(b)) {
  129. System.out.println("Step 11");
  130. i++;
  131. }
  132. if (b.trim().contains(c)) {
  133. System.out.println("Step 12");
  134. i++;
  135. }
  136. if (c.trim().contains(d)) {
  137. System.out.println("Step 13");
  138. i++;
  139. }
  140. /*if (i == 13) {
  141. throw new RuntimeException ("look at this");
  142. }*/
  143. }
  144. }
  145. }