diff --git a/green_pattern/.gitignore b/green_pattern/.gitignore new file mode 100644 index 0000000..20f1e21 --- /dev/null +++ b/green_pattern/.gitignore @@ -0,0 +1,2 @@ +*.class +__pycache__/ \ No newline at end of file diff --git a/green_pattern/binary_search/after_12.jar b/green_pattern/binary_search/after_12.jar new file mode 100644 index 0000000..1b574ff Binary files /dev/null and b/green_pattern/binary_search/after_12.jar differ diff --git a/green_pattern/binary_search/before_12.jar b/green_pattern/binary_search/before_12.jar new file mode 100644 index 0000000..7e92586 Binary files /dev/null and b/green_pattern/binary_search/before_12.jar differ diff --git a/green_pattern/checkSubmission.py b/green_pattern/checkSubmission.py new file mode 100644 index 0000000..67c24b8 --- /dev/null +++ b/green_pattern/checkSubmission.py @@ -0,0 +1,25 @@ + +import time +import subprocess +import warnings + +warnings.filterwarnings("ignore", category=DeprecationWarning) + +from os import listdir +from os.path import isfile, join + +jar_files = [f for f in listdir("./submission/") if isfile(join("./submission/", f))] + +for jar_name in jar_files: + execution_result = subprocess.run(["java", "-jar", f"{jar_name}"], capture_output=True, cwd=f'./submission') + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + print(f"*******{jar_name} runtime error*******") + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + exit(0) + +print("===All files executed successfully===") +print("======You are ready to submit!!======") \ No newline at end of file diff --git a/green_pattern/compileAll.py b/green_pattern/compileAll.py new file mode 100644 index 0000000..4db3bc3 --- /dev/null +++ b/green_pattern/compileAll.py @@ -0,0 +1,19 @@ +import subprocess + +from os import listdir +from os.path import isfile, join + +patterns = [f for f in listdir("./patterns/") if not isfile(join("./patterns/", f))] + +for dir_name in patterns: + bef_compilation_result = subprocess.run(["javac", "Before.java"], capture_output=True, cwd=f'./patterns/{dir_name}') + aft_compilation_result = subprocess.run(["javac", "After.java" ], capture_output=True, cwd=f'./patterns/{dir_name}') + try: + bef_compilation_result.check_returncode() + aft_compilation_result.check_returncode() + except subprocess.CalledProcessError as err: + bef_raw_err = bef_compilation_result.stderr + aft_raw_err = aft_compilation_result.stderr + err = bef_raw_err.decode("unicode_escape").strip() + "\n" + aft_raw_err.decode("unicode_escape").strip() + print(err) + exit(0) diff --git a/green_pattern/compressAll.py b/green_pattern/compressAll.py new file mode 100644 index 0000000..ed7b63c --- /dev/null +++ b/green_pattern/compressAll.py @@ -0,0 +1,27 @@ +import subprocess + +from os import listdir +from os.path import isfile, join + +patterns = [f for f in listdir("./patterns/") if not isfile(join("./patterns/", f))] + +for dir_name in patterns: + srcfiles = listdir(f"./patterns/{dir_name}") + + rmfiles = ["After.java", "Before.java", "After.class", "Before.class", "after.jar", "before.jar"] + for file in rmfiles: + if file in srcfiles: + srcfiles.remove(file) + + bef_compression_result = subprocess.run(["jar", "cfe", "before.jar", "Before", "Before.class", *srcfiles], capture_output=True, cwd=f'./patterns/{dir_name}') + aft_compression_result = subprocess.run(["jar", "cfe", "after.jar", "After", "After.class", *srcfiles], capture_output=True, cwd=f'./patterns/{dir_name}') + try: + bef_compression_result.check_returncode() + aft_compression_result.check_returncode() + except subprocess.CalledProcessError as err: + bef_raw_err = bef_compression_result.stderr + aft_raw_err = aft_compression_result.stderr + err = bef_raw_err.decode("unicode_escape").strip() + "\n" + aft_raw_err.decode("unicode_escape").strip() + print(err) + exit(0) + diff --git a/green_pattern/evaluateAll.py b/green_pattern/evaluateAll.py new file mode 100644 index 0000000..d15e6fe --- /dev/null +++ b/green_pattern/evaluateAll.py @@ -0,0 +1,49 @@ + +import time +import subprocess +import warnings + +warnings.filterwarnings("ignore", category=DeprecationWarning) + +from os import listdir +from os.path import isfile, join + +patterns = [f for f in listdir("./patterns/") if not isfile(join("./patterns/", f))] + +for dir_name in patterns: + # measure Before.java execution time + + bef_execution_time = 0 + start_time = time.perf_counter() + execution_result = subprocess.run(["java", "-jar", "before.jar"], capture_output=True, cwd=f'./patterns/{dir_name}') + bef_execution_time += (time.perf_counter()-start_time) + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + + # measure After.java execution time + aft_execution_time = 0 + start_time = time.perf_counter() + execution_result = subprocess.run(["java", "-jar", "after.jar"], capture_output=True, cwd=f'./patterns/{dir_name}') + aft_execution_time += (time.perf_counter()-start_time) + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + + print(f"============= Result ({dir_name}) =============") + print(f"[Before.jar] runtime: {bef_execution_time:0.4f}s") + print(f"[After.jar ] runtime: {aft_execution_time:0.4f}s") + if bef_execution_time > aft_execution_time: + print(f"=> runtime decreased by {bef_execution_time-aft_execution_time:0.4f}s") + else: + print("=> runtime has not decreased...") \ No newline at end of file diff --git a/green_pattern/pattern_template/After.java b/green_pattern/pattern_template/After.java new file mode 100644 index 0000000..070834d --- /dev/null +++ b/green_pattern/pattern_template/After.java @@ -0,0 +1,5 @@ +public class After { + public static void main(String[] args){ + // write after code + } +} \ No newline at end of file diff --git a/green_pattern/pattern_template/Before.java b/green_pattern/pattern_template/Before.java new file mode 100644 index 0000000..b4617e5 --- /dev/null +++ b/green_pattern/pattern_template/Before.java @@ -0,0 +1,5 @@ +public class Before { + public static void main(String[] args){ + // write before code + } +} \ No newline at end of file diff --git a/green_pattern/patterns/Arrays_parallelsort/After.java b/green_pattern/patterns/Arrays_parallelsort/After.java new file mode 100644 index 0000000..eb35b8b --- /dev/null +++ b/green_pattern/patterns/Arrays_parallelsort/After.java @@ -0,0 +1,18 @@ +import java.util.Arrays; +import java.util.Random; + +public class After { + + public static void main(String[] args) { + for (int k = 0 ; k < 1000 ; k++){ + int[] data = new int[1000000]; + Random random = new Random(); + + + for (int i = 0; i < data.length; i++) { + data[i] = random.nextInt(1000000); + } + Arrays.parallelSort(data); + } + } +} diff --git a/green_pattern/patterns/Arrays_parallelsort/Before.java b/green_pattern/patterns/Arrays_parallelsort/Before.java new file mode 100644 index 0000000..f788674 --- /dev/null +++ b/green_pattern/patterns/Arrays_parallelsort/Before.java @@ -0,0 +1,17 @@ +import java.util.Arrays; +import java.util.Random; + +public class Before { + + public static void main(String[] args) { + for (int k = 0 ; k < 1000 ; k++){ + int[] data = new int[1000000]; + Random random = new Random(); + + for (int i = 0; i < data.length; i++) { + data[i] = random.nextInt(1000000); + } + Arrays.sort(data); + } + } +} diff --git a/green_pattern/patterns/Arrays_parallelsort/after.jar b/green_pattern/patterns/Arrays_parallelsort/after.jar new file mode 100644 index 0000000..e5ffb8d Binary files /dev/null and b/green_pattern/patterns/Arrays_parallelsort/after.jar differ diff --git a/green_pattern/patterns/Arrays_parallelsort/before.jar b/green_pattern/patterns/Arrays_parallelsort/before.jar new file mode 100644 index 0000000..42b8e47 Binary files /dev/null and b/green_pattern/patterns/Arrays_parallelsort/before.jar differ diff --git a/green_pattern/patterns/Enhanced_for_Loop/After.java b/green_pattern/patterns/Enhanced_for_Loop/After.java new file mode 100644 index 0000000..9fbec7f --- /dev/null +++ b/green_pattern/patterns/Enhanced_for_Loop/After.java @@ -0,0 +1,13 @@ +import java.util.Arrays; + +public class After { + public static void main(String[] args) { + int[] array = new int[10000000]; + + + for (int num : array) { + num = num * 2; + } + + } +} diff --git a/green_pattern/patterns/Enhanced_for_Loop/Before.java b/green_pattern/patterns/Enhanced_for_Loop/Before.java new file mode 100644 index 0000000..3020533 --- /dev/null +++ b/green_pattern/patterns/Enhanced_for_Loop/Before.java @@ -0,0 +1,13 @@ +import java.util.Arrays; + +public class Before { + public static void main(String[] args) { + int[] array = new int[10000000]; + + + for (int i = 0; i < array.length; i++) { + array[i] = array[i] * 2; + } + + } +} diff --git a/green_pattern/patterns/Enhanced_for_Loop/after.jar b/green_pattern/patterns/Enhanced_for_Loop/after.jar new file mode 100644 index 0000000..0174d3a Binary files /dev/null and b/green_pattern/patterns/Enhanced_for_Loop/after.jar differ diff --git a/green_pattern/patterns/Enhanced_for_Loop/before.jar b/green_pattern/patterns/Enhanced_for_Loop/before.jar new file mode 100644 index 0000000..2d6b960 Binary files /dev/null and b/green_pattern/patterns/Enhanced_for_Loop/before.jar differ diff --git a/green_pattern/patterns/For_optimization/After.java b/green_pattern/patterns/For_optimization/After.java new file mode 100644 index 0000000..2402368 --- /dev/null +++ b/green_pattern/patterns/For_optimization/After.java @@ -0,0 +1,24 @@ +import java.util.stream.IntStream; + + +public class After { + public static void main(String[] args) { + long sum = 0; + + for(int k = 0 ; k < 100 ; k++){ + int[] arr = IntStream.range(1,100000000).toArray(); + int len = arr.length; + int i; + + for (i = 0; i < len - 10; i += 10) { + sum += arr[i] + arr[i + 1] + arr[i + 2] + arr[i + 3] + arr[i+4] + arr[i + 5] + arr[i + 6] + arr[i + 7] + arr[i+8] + arr[i + 9]; + } + + while (i < len) { + sum += arr[i]; + i++; + } + } + System.out.println(sum); + } +} diff --git a/green_pattern/patterns/For_optimization/Before.java b/green_pattern/patterns/For_optimization/Before.java new file mode 100644 index 0000000..328a8fb --- /dev/null +++ b/green_pattern/patterns/For_optimization/Before.java @@ -0,0 +1,19 @@ +import java.util.stream.IntStream; + + +public class Before { + public static void main(String[] args) { + long sum = 0; + + for(int k = 0 ; k < 100 ; k++){ + int[] arr = IntStream.range(1,100000000).toArray(); + int len = arr.length; + int i; + + for (i = 0 ; i < len ; i++) { + sum += arr[i]; + } + } + System.out.println(sum); + } +} diff --git a/green_pattern/patterns/For_optimization/after.jar b/green_pattern/patterns/For_optimization/after.jar new file mode 100644 index 0000000..e6d15d8 Binary files /dev/null and b/green_pattern/patterns/For_optimization/after.jar differ diff --git a/green_pattern/patterns/For_optimization/before.jar b/green_pattern/patterns/For_optimization/before.jar new file mode 100644 index 0000000..6e528f2 Binary files /dev/null and b/green_pattern/patterns/For_optimization/before.jar differ diff --git a/green_pattern/patterns/Garbage_collect_optim/After.java b/green_pattern/patterns/Garbage_collect_optim/After.java new file mode 100644 index 0000000..bd7b2e7 --- /dev/null +++ b/green_pattern/patterns/Garbage_collect_optim/After.java @@ -0,0 +1,12 @@ +public class After { + + public static void main(String[] args) { + for (int i = 0; i < 100000; i++) { + + String myString2 = "Object " + i; + System.out.println(myString2); + + myString2 = null; + } + } +} diff --git a/green_pattern/patterns/Garbage_collect_optim/Before.java b/green_pattern/patterns/Garbage_collect_optim/Before.java new file mode 100644 index 0000000..04bf09e --- /dev/null +++ b/green_pattern/patterns/Garbage_collect_optim/Before.java @@ -0,0 +1,9 @@ +public class Before { + public static void main(String[] args) { + for (int i = 0; i < 100000; i++) { + + String myString = new String("Object " + i); + System.out.println(myString); + } + } +} diff --git a/green_pattern/patterns/Garbage_collect_optim/after.jar b/green_pattern/patterns/Garbage_collect_optim/after.jar new file mode 100644 index 0000000..23bae8f Binary files /dev/null and b/green_pattern/patterns/Garbage_collect_optim/after.jar differ diff --git a/green_pattern/patterns/Garbage_collect_optim/before.jar b/green_pattern/patterns/Garbage_collect_optim/before.jar new file mode 100644 index 0000000..67bb836 Binary files /dev/null and b/green_pattern/patterns/Garbage_collect_optim/before.jar differ diff --git a/green_pattern/patterns/HashMap_than_TreeMap/After.java b/green_pattern/patterns/HashMap_than_TreeMap/After.java new file mode 100644 index 0000000..b45aeea --- /dev/null +++ b/green_pattern/patterns/HashMap_than_TreeMap/After.java @@ -0,0 +1,20 @@ +import java.util.HashMap; +import java.util.Map; + + +public class After { + public static void main(String[] args) { + + for (int i = 0 ; i < 100000 ; i++){ + Map hashMap = new HashMap<>(); + hashMap.put("Alice", 25); + hashMap.put("Bob", 30); + hashMap.put("Eve", 22); + + + for (Map.Entry entry : hashMap.entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + } + } + } +} diff --git a/green_pattern/patterns/HashMap_than_TreeMap/Before.java b/green_pattern/patterns/HashMap_than_TreeMap/Before.java new file mode 100644 index 0000000..2d4fe2c --- /dev/null +++ b/green_pattern/patterns/HashMap_than_TreeMap/Before.java @@ -0,0 +1,18 @@ +import java.util.Map; +import java.util.TreeMap; + +public class Before { + public static void main(String[] args) { + + for (int i = 0 ; i < 100000 ; i++){ + Map treeMap = new TreeMap<>(); + treeMap.put("Alice", 25); + treeMap.put("Bob", 30); + treeMap.put("Eve", 22); + + for (Map.Entry entry : treeMap.entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + } + } + } +} diff --git a/green_pattern/patterns/HashMap_than_TreeMap/after.jar b/green_pattern/patterns/HashMap_than_TreeMap/after.jar new file mode 100644 index 0000000..c63d01b Binary files /dev/null and b/green_pattern/patterns/HashMap_than_TreeMap/after.jar differ diff --git a/green_pattern/patterns/HashMap_than_TreeMap/before.jar b/green_pattern/patterns/HashMap_than_TreeMap/before.jar new file mode 100644 index 0000000..55319a0 Binary files /dev/null and b/green_pattern/patterns/HashMap_than_TreeMap/before.jar differ diff --git a/green_pattern/patterns/Row-major_than_Column-major/After.java b/green_pattern/patterns/Row-major_than_Column-major/After.java new file mode 100644 index 0000000..40c9bd5 --- /dev/null +++ b/green_pattern/patterns/Row-major_than_Column-major/After.java @@ -0,0 +1,28 @@ +import java.util.Random; + +public class After { + public static void main(String[] args) { + long totalSum = 0; + for (int p = 0 ; p < 1000 ; p++){ + int rows = 1000; + int cols = 1000; + int[][] array = new int[rows][cols]; + Random random = new Random(); + + + for (int i = 0; i < rows; i++) { + for (int k = 0; k < cols; k++) { + array[i][k] = random.nextInt(100); + } + } + + for (int i = 0; i < array.length; i++) { + int[] row = array[i]; + for (int k = 0; k < row.length; k++) { + totalSum += row[k]; + } + } + } + System.out.println(totalSum); + } +} diff --git a/green_pattern/patterns/Row-major_than_Column-major/Before.java b/green_pattern/patterns/Row-major_than_Column-major/Before.java new file mode 100644 index 0000000..d766450 --- /dev/null +++ b/green_pattern/patterns/Row-major_than_Column-major/Before.java @@ -0,0 +1,28 @@ +import java.util.Random; + +public class Before { + public static void main(String[] args) { + long totalSum = 0; + for (int p = 0 ; p < 1000 ; p++){ + int rows = 1000; + int cols = 1000; + int[][] array = new int[rows][cols]; + Random random = new Random(); + + + for (int k = 0; k < cols; k++) { + for (int i = 0; i < rows; i++) { + array[i][k] = random.nextInt(100); + } + } + + for (int k = 0; k < cols; k++) { + for (int i = 0 ; i < rows ; i++){ + totalSum += array[i][k]; + } + + } + } + System.out.println(totalSum); + } +} diff --git a/green_pattern/patterns/Row-major_than_Column-major/after.jar b/green_pattern/patterns/Row-major_than_Column-major/after.jar new file mode 100644 index 0000000..6d300bb Binary files /dev/null and b/green_pattern/patterns/Row-major_than_Column-major/after.jar differ diff --git a/green_pattern/patterns/Row-major_than_Column-major/before.jar b/green_pattern/patterns/Row-major_than_Column-major/before.jar new file mode 100644 index 0000000..71cead4 Binary files /dev/null and b/green_pattern/patterns/Row-major_than_Column-major/before.jar differ diff --git a/green_pattern/patterns/Sequntial_than_Parallel/After.java b/green_pattern/patterns/Sequntial_than_Parallel/After.java new file mode 100644 index 0000000..215f1db --- /dev/null +++ b/green_pattern/patterns/Sequntial_than_Parallel/After.java @@ -0,0 +1,25 @@ +import java.util.ArrayList; +import java.util.List; + +public class After { + + public static void main(String[] args) { + for (int k = 0 ; k < 1000 ; k++){ + List numbers = new ArrayList<>(); + for (int i = 1; i <= 1000000; i++) { + numbers.add(i); + } + + List evenSquares = new ArrayList<>(); + for (int number : numbers) { + if (number % 2 == 0) { + evenSquares.add(number * number); + } + } + + for (int i = 0; i < 10; i++) { + System.out.println(evenSquares.get(i)); + } + } + } +} diff --git a/green_pattern/patterns/Sequntial_than_Parallel/Before.java b/green_pattern/patterns/Sequntial_than_Parallel/Before.java new file mode 100644 index 0000000..7a1b952 --- /dev/null +++ b/green_pattern/patterns/Sequntial_than_Parallel/Before.java @@ -0,0 +1,22 @@ +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + + + +public class Before { + + public static void main(String[] args) { + for (int k = 0 ; k < 1000 ; k++){ + List numbers = IntStream.rangeClosed(1, 1000000) + .boxed() + .collect(Collectors.toList()); + + List evenSquares = numbers.stream() + .filter(number -> number % 2 == 0) + .map(number -> number * number) + .collect(Collectors.toList()); + evenSquares.stream().limit(10).forEach(System.out::println); + } + } +} diff --git a/green_pattern/patterns/Sequntial_than_Parallel/after.jar b/green_pattern/patterns/Sequntial_than_Parallel/after.jar new file mode 100644 index 0000000..b31f250 Binary files /dev/null and b/green_pattern/patterns/Sequntial_than_Parallel/after.jar differ diff --git a/green_pattern/patterns/Sequntial_than_Parallel/before.jar b/green_pattern/patterns/Sequntial_than_Parallel/before.jar new file mode 100644 index 0000000..e13f104 Binary files /dev/null and b/green_pattern/patterns/Sequntial_than_Parallel/before.jar differ diff --git a/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/After.java b/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/After.java new file mode 100644 index 0000000..bcc4037 --- /dev/null +++ b/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/After.java @@ -0,0 +1,15 @@ +import java.util.ArrayList; +import java.util.List; + +public class After { + public static void main(String[] args) { + int n = 1000000; + + + List list2 = new ArrayList<>(n); + for (int i = 0; i < n; i++) { + list2.add(i); + } + + } +} diff --git a/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/Before.java b/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/Before.java new file mode 100644 index 0000000..cafd3e7 --- /dev/null +++ b/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/Before.java @@ -0,0 +1,15 @@ +import java.util.ArrayList; +import java.util.List; + +public class Before { + public static void main(String[] args) { + int n = 1000000; + + + List list1 = new ArrayList<>(); + for (int i = 0; i < n; i++) { + list1.add(i); + } + + } +} diff --git a/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/after.jar b/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/after.jar new file mode 100644 index 0000000..16cd280 Binary files /dev/null and b/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/after.jar differ diff --git a/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/before.jar b/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/before.jar new file mode 100644 index 0000000..458c37d Binary files /dev/null and b/green_pattern/patterns/Setting_Initial_Capacity_for_Collections/before.jar differ diff --git a/green_pattern/patterns/Simple_power_calculation/After.java b/green_pattern/patterns/Simple_power_calculation/After.java new file mode 100644 index 0000000..2ed2f36 --- /dev/null +++ b/green_pattern/patterns/Simple_power_calculation/After.java @@ -0,0 +1,12 @@ +public class After { + + public static void main(String[] args) { + for (int k = 0 ; k < 1000 ; k++){ + int n = 1000000; + double base =3.0; + for (int i = 0; i < n; i++) { + // double result = base^i; + } + } + } +} diff --git a/green_pattern/patterns/Simple_power_calculation/Before.java b/green_pattern/patterns/Simple_power_calculation/Before.java new file mode 100644 index 0000000..b333e73 --- /dev/null +++ b/green_pattern/patterns/Simple_power_calculation/Before.java @@ -0,0 +1,13 @@ +public class Before { + + public static void main(String[] args) { + + for (int k = 0 ; k < 1000 ; k++){ + int n = 1000000; + double base =3.0; + for (int i = 0; i < n; i++) { + double result = Math.pow(base,i); + } + } + } +} diff --git a/green_pattern/patterns/Simple_power_calculation/after.jar b/green_pattern/patterns/Simple_power_calculation/after.jar new file mode 100644 index 0000000..4a23308 Binary files /dev/null and b/green_pattern/patterns/Simple_power_calculation/after.jar differ diff --git a/green_pattern/patterns/Simple_power_calculation/before.jar b/green_pattern/patterns/Simple_power_calculation/before.jar new file mode 100644 index 0000000..630c53c Binary files /dev/null and b/green_pattern/patterns/Simple_power_calculation/before.jar differ diff --git a/green_pattern/patterns/Sublist_Deletion_Optim/After.java b/green_pattern/patterns/Sublist_Deletion_Optim/After.java new file mode 100644 index 0000000..6dfa7c8 --- /dev/null +++ b/green_pattern/patterns/Sublist_Deletion_Optim/After.java @@ -0,0 +1,22 @@ +import java.util.ArrayList; +import java.util.List; + +public class After { + private static String generateData() { + return "Some data"; + } + + public static void main(String[] args) { + List data = new ArrayList<>(); + int i = 0; + + while (i < 200000) { + data.add(generateData()); + i++; + } + + int startIndex = 0; + int endIndex = 100000; + data.subList(startIndex, endIndex + 1).clear(); + } +} diff --git a/green_pattern/patterns/Sublist_Deletion_Optim/Before.java b/green_pattern/patterns/Sublist_Deletion_Optim/Before.java new file mode 100644 index 0000000..d71a7bf --- /dev/null +++ b/green_pattern/patterns/Sublist_Deletion_Optim/Before.java @@ -0,0 +1,23 @@ +import java.util.ArrayList; +import java.util.List; + +public class Before { + private static String generateData() { + return "Some data"; + } + + public static void main(String[] args) { + List data = new ArrayList<>(); + int i = 0;int j = 0; + + while ( i < 200000) { + data.add(generateData()); + i++; + } + + while(j < 100000) { + data.remove(0); + j++; + } + } +} diff --git a/green_pattern/patterns/Sublist_Deletion_Optim/after.jar b/green_pattern/patterns/Sublist_Deletion_Optim/after.jar new file mode 100644 index 0000000..3710c7b Binary files /dev/null and b/green_pattern/patterns/Sublist_Deletion_Optim/after.jar differ diff --git a/green_pattern/patterns/Sublist_Deletion_Optim/before.jar b/green_pattern/patterns/Sublist_Deletion_Optim/before.jar new file mode 100644 index 0000000..2fe0290 Binary files /dev/null and b/green_pattern/patterns/Sublist_Deletion_Optim/before.jar differ diff --git a/green_pattern/patterns/Switch_than_ifelse/After.java b/green_pattern/patterns/Switch_than_ifelse/After.java new file mode 100644 index 0000000..02f767d --- /dev/null +++ b/green_pattern/patterns/Switch_than_ifelse/After.java @@ -0,0 +1,38 @@ +public class After { + + public static void main(String[] args) { + for(int i = 0 ; i < 100000 ; i++){ + int dayOfWeek = 3; + + String day; + switch (dayOfWeek) { + case 1: + day = "Sunday"; + break; + case 2: + day = "Monday"; + break; + case 3: + day = "Tuesday"; + break; + case 4: + day = "Wednsday"; + break; + case 5: + day = "Thursday"; + break; + case 6: + day = "Friday"; + break; + case 7: + day = "Saturday"; + break; + + default: + day = "Unknown"; + } + + System.out.println("Day of the week: " + day); + } + } +} diff --git a/green_pattern/patterns/Switch_than_ifelse/Before.java b/green_pattern/patterns/Switch_than_ifelse/Before.java new file mode 100644 index 0000000..978a5d4 --- /dev/null +++ b/green_pattern/patterns/Switch_than_ifelse/Before.java @@ -0,0 +1,40 @@ +public class Before { + + public static void main(String[] args) { + for(int i = 0 ; i < 100000 ; i++){ + int dayOfWeek = 6; + + String day; + if(dayOfWeek == 1) { + day = "Sunday"; + } + + else if(dayOfWeek == 2){ + day = "Monday"; + } + + else if(dayOfWeek == 3) { + day = "Tuesday"; + } + else if(dayOfWeek == 4){ + day = "Wednsday"; + } + else if(dayOfWeek == 5){ + day = "Thursday"; + } + else if(dayOfWeek == 6){ + day = "Friday"; + } + else if(dayOfWeek == 7){ + day = "Saturday"; + } + + else { + day = "Unknown"; + } + + + System.out.println("Day of the week: " + day); + } + } +} diff --git a/green_pattern/patterns/Switch_than_ifelse/after.jar b/green_pattern/patterns/Switch_than_ifelse/after.jar new file mode 100644 index 0000000..cffb0cd Binary files /dev/null and b/green_pattern/patterns/Switch_than_ifelse/after.jar differ diff --git a/green_pattern/patterns/Switch_than_ifelse/before.jar b/green_pattern/patterns/Switch_than_ifelse/before.jar new file mode 100644 index 0000000..50f27bd Binary files /dev/null and b/green_pattern/patterns/Switch_than_ifelse/before.jar differ diff --git a/green_pattern/patterns/bfs/After.jar b/green_pattern/patterns/bfs/After.jar new file mode 100644 index 0000000..b717350 Binary files /dev/null and b/green_pattern/patterns/bfs/After.jar differ diff --git a/green_pattern/patterns/bfs/After.java b/green_pattern/patterns/bfs/After.java new file mode 100644 index 0000000..231f826 --- /dev/null +++ b/green_pattern/patterns/bfs/After.java @@ -0,0 +1,63 @@ +import java.util.LinkedList; +import java.util.Queue; + +public class After { + static int[][] dir = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; + static int row = 4; + static int col = 6; + static int[][] vec = new int[row][col]; + static int[][] visited = new int[row][col]; + + public static void bfs(int y, int x) { + Queue q = new LinkedList<>(); + q.add(new int[]{y, x}); + visited[y][x] = 1; + + while (!q.isEmpty()) { + int[] curr = q.poll(); + + if(curr[0] == row-1 && curr[1] == col-1){ + return; + } + + for (int i = 0; i < 4; i++) { + int ny = curr[0] + dir[i][0]; + int nx = curr[1] + dir[i][1]; + + if (ny < 0 || ny >= row || nx < 0 || nx >= col) { + continue; + } + + if (visited[ny][nx] >= 1) { + continue; + } + + if (vec[ny][nx] == 0) { + continue; + } + + q.add(new int[]{ny, nx}); + visited[ny][nx] = visited[curr[0]][curr[1]] + 1; + } + } + } + + public static void main(String[] args){ + long begin = System.currentTimeMillis(); + + vec = new int[][]{ + {1, 1, 1, 1, 1, 1}, + {1, 0, 1, 1, 0, 0}, + {1, 1, 0, 0, 0, 0}, + {0, 1, 1, 1, 1, 1} + }; + + for(int i=0; i<1000000; i++){ + visited = new int[row][col]; + bfs(0, 0); + } + + long dur = System.currentTimeMillis() - begin; + System.out.println("Execution Time: " + dur/1000.0 + " seconds"); + } +} diff --git a/green_pattern/patterns/bfs/Before.jar b/green_pattern/patterns/bfs/Before.jar new file mode 100644 index 0000000..0c6da6d Binary files /dev/null and b/green_pattern/patterns/bfs/Before.jar differ diff --git a/green_pattern/patterns/bfs/Before.java b/green_pattern/patterns/bfs/Before.java new file mode 100644 index 0000000..c3ba6a0 --- /dev/null +++ b/green_pattern/patterns/bfs/Before.java @@ -0,0 +1,48 @@ +public class Before { + static int[][] dir = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; + static int row = 4; + static int col = 6; + static int[][] vec = new int[row][col]; + static int[][] visited = new int[row][col]; + + public static void dfs(int y, int x) { + if (y == row - 1 && x == col - 1) { + return; + } + + for (int i = 0; i < 4; i++) { + int ny = y + dir[i][0]; + int nx = x + dir[i][1]; + + if (ny < 0 || ny >= row || nx < 0 || nx >= col) { + continue; + } + + if (visited[ny][nx] >= 1) { + continue; + } + + if (vec[ny][nx] == 0) { + continue; + } + + visited[ny][nx] = visited[y][x] + 1; + dfs(ny, nx); + visited[ny][nx] = 0; + } + } + + public static void main(String[] args){ + vec = new int[][]{ + {1, 1, 1, 1, 1, 1}, + {1, 0, 1, 1, 0, 0}, + {1, 1, 0, 0, 0, 0}, + {0, 1, 1, 1, 1, 1} + }; + + for(int i=0; i<1000000; i++){ + visited = new int[row][col]; + dfs(0, 0); + } + } +} diff --git a/green_pattern/patterns/binary_search/After.jar b/green_pattern/patterns/binary_search/After.jar new file mode 100644 index 0000000..e391d7f Binary files /dev/null and b/green_pattern/patterns/binary_search/After.jar differ diff --git a/green_pattern/patterns/binary_search/After.java b/green_pattern/patterns/binary_search/After.java new file mode 100644 index 0000000..700f65e --- /dev/null +++ b/green_pattern/patterns/binary_search/After.java @@ -0,0 +1,27 @@ +import java.util.ArrayList; + +public class After { + public static void binarySearch(ArrayList nums, int target) { + int start = 0; + int end = nums.size() - 1; + + while (start <= end) { + int mid = start + (end - start) / 2; + if (nums.get(mid) == target) { + break; + } else if (nums.get(mid) < target) { + start = mid + 1; + } else { + end = mid - 1; + } + } + } + + public static void main(String[] args){ + ArrayList v = new ArrayList(); + for(int i=0; i<100000; i++) { + v.add(i); + binarySearch(v, i); + } + } +} diff --git a/green_pattern/patterns/binary_search/Before.jar b/green_pattern/patterns/binary_search/Before.jar new file mode 100644 index 0000000..9b9b97b Binary files /dev/null and b/green_pattern/patterns/binary_search/Before.jar differ diff --git a/green_pattern/patterns/binary_search/Before.java b/green_pattern/patterns/binary_search/Before.java new file mode 100644 index 0000000..4ec0d80 --- /dev/null +++ b/green_pattern/patterns/binary_search/Before.java @@ -0,0 +1,19 @@ +import java.util.ArrayList; + +public class Before { + public static void linearSearch(ArrayList nums, int target) { + for (int i = 0; i < nums.size(); i++) { + if (nums.get(i) == target) { + break; + } + } + } + + public static void main(String[] args){ + ArrayList v = new ArrayList(); + for(int i=0; i<100000; i++) { + v.add(i); + linearSearch(v, i); + } + } +} diff --git a/green_pattern/patterns/cache_utilization/After.java b/green_pattern/patterns/cache_utilization/After.java new file mode 100644 index 0000000..e8e33ba --- /dev/null +++ b/green_pattern/patterns/cache_utilization/After.java @@ -0,0 +1,17 @@ +import java.util.regex.Pattern; + +public class After { + private static final Pattern ROMAN = Pattern.compile( + "^(?=.)M*(C[MD]|D?C{0,3})" + + "(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$" + ); + static boolean isRomanNumeralFast(String s) { + return ROMAN.matcher(s).matches(); + } + public static void main(String[] args){ + int iterations = 1000000; + for(int i=0; i l = new LinkedList(); + for(int i=0; i<100000; i++) { + l.add(1); + } + for(int i=0; i<100000; i++) { + l.removeFirst(); + } + } +} + diff --git a/green_pattern/patterns/linked_list/Before.jar b/green_pattern/patterns/linked_list/Before.jar new file mode 100644 index 0000000..0ea798c Binary files /dev/null and b/green_pattern/patterns/linked_list/Before.jar differ diff --git a/green_pattern/patterns/linked_list/Before.java b/green_pattern/patterns/linked_list/Before.java new file mode 100644 index 0000000..38d1ff5 --- /dev/null +++ b/green_pattern/patterns/linked_list/Before.java @@ -0,0 +1,14 @@ +import java.util.ArrayList; + +public class Before { + public static void main(String[] args){ + ArrayList v = new ArrayList(); + for(int i=0; i<100000; i++) { + v.add(1); + } + for(int i=0; i<100000; i++) { + v.remove(0); + } + } +} + diff --git a/green_pattern/patterns/no_debug_log/After.java b/green_pattern/patterns/no_debug_log/After.java new file mode 100644 index 0000000..a011725 --- /dev/null +++ b/green_pattern/patterns/no_debug_log/After.java @@ -0,0 +1,12 @@ +public class After { + public static void main(String[] args) { + for (int i = 0; i < 10000; i++) { + // System.out.println("Current index: " + i); + int result = process(i); + } + } + + private static int process(int value) { + return value * 2; + } +} diff --git a/green_pattern/patterns/no_debug_log/Before.java b/green_pattern/patterns/no_debug_log/Before.java new file mode 100644 index 0000000..0bb2022 --- /dev/null +++ b/green_pattern/patterns/no_debug_log/Before.java @@ -0,0 +1,12 @@ +public class Before { + public static void main(String[] args) { + for (int i = 0; i < 10000; i++) { + System.out.println("Current index: " + i); + int result = process(i); + } + } + + private static int process(int value) { + return value * 2; + } +} diff --git a/green_pattern/patterns/no_debug_log/after.jar b/green_pattern/patterns/no_debug_log/after.jar new file mode 100644 index 0000000..bd8fa79 Binary files /dev/null and b/green_pattern/patterns/no_debug_log/after.jar differ diff --git a/green_pattern/patterns/no_debug_log/before.jar b/green_pattern/patterns/no_debug_log/before.jar new file mode 100644 index 0000000..1f6a5fe Binary files /dev/null and b/green_pattern/patterns/no_debug_log/before.jar differ diff --git a/green_pattern/patterns/no_range_when_init_array/After.java b/green_pattern/patterns/no_range_when_init_array/After.java new file mode 100644 index 0000000..f85f828 --- /dev/null +++ b/green_pattern/patterns/no_range_when_init_array/After.java @@ -0,0 +1,13 @@ +import java.util.Arrays; +public class After { + public static void main(String[] args){ + int iterations = 100000; + int intArray[] = new int[iterations]; + for(int i=1; i> pool = new LinkedList<>(); + + public static Object getObject() { + if(pool.isEmpty()) { + return new Object(); + } else { + return pool.poll(); + } + } + + public static void returnObject(ArrayList object) { + if(pool.size() < MAX_POOL_SIZE) { + pool.add(object); + } + } + } + + public static void main(String[] args){ + for(int i=0; i<100000; i++) { + ObjectPool.getObject(); + } + } +} \ No newline at end of file diff --git a/green_pattern/patterns/object_pooling/Before.jar b/green_pattern/patterns/object_pooling/Before.jar new file mode 100644 index 0000000..73101fd Binary files /dev/null and b/green_pattern/patterns/object_pooling/Before.jar differ diff --git a/green_pattern/patterns/object_pooling/Before.java b/green_pattern/patterns/object_pooling/Before.java new file mode 100644 index 0000000..ecd4ea8 --- /dev/null +++ b/green_pattern/patterns/object_pooling/Before.java @@ -0,0 +1,9 @@ +import java.util.ArrayList; + +public class Before { + public static void main(String[] args){ + for(int i=0; i<100000; i++) { + new ArrayList<>(i); + } + } +} \ No newline at end of file diff --git a/green_pattern/patterns/object_to_literal/After.java b/green_pattern/patterns/object_to_literal/After.java new file mode 100644 index 0000000..ea9f5b4 --- /dev/null +++ b/green_pattern/patterns/object_to_literal/After.java @@ -0,0 +1,16 @@ +public class After { + public static void main(String[] args){ + String[] s1 = new String[100]; + Boolean[] b1 = new Boolean[100]; + + int iterations = 1000000; + for(int i=0; i list = new ArrayList<>(); + Map map = new HashMap<>(); + list.clear(); + map.clear(); + list = null; + map = null; + } +} \ No newline at end of file diff --git a/green_pattern/patterns/obsolete_map/Before.java b/green_pattern/patterns/obsolete_map/Before.java new file mode 100644 index 0000000..866b91f --- /dev/null +++ b/green_pattern/patterns/obsolete_map/Before.java @@ -0,0 +1,13 @@ +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.List; + +public class Before { + public static void main(String[] args){ + List list = new ArrayList<>(); + Map map = new HashMap<>(); + list.clear(); + map.clear(); + } +} \ No newline at end of file diff --git a/green_pattern/patterns/obsolete_map/after.jar b/green_pattern/patterns/obsolete_map/after.jar new file mode 100644 index 0000000..fe41f7c Binary files /dev/null and b/green_pattern/patterns/obsolete_map/after.jar differ diff --git a/green_pattern/patterns/obsolete_map/before.jar b/green_pattern/patterns/obsolete_map/before.jar new file mode 100644 index 0000000..465e54c Binary files /dev/null and b/green_pattern/patterns/obsolete_map/before.jar differ diff --git a/green_pattern/patterns/obsolete_stack/After.java b/green_pattern/patterns/obsolete_stack/After.java new file mode 100644 index 0000000..74565ae --- /dev/null +++ b/green_pattern/patterns/obsolete_stack/After.java @@ -0,0 +1,22 @@ +public class After { + public static int size; + public static Object pop(String[] stack) { + if (size==0) { + return -1; + } + Object result = stack[--size]; + stack[size] = null; + return result; + } + public static void main(String[] args){ + String a[] = new String[10000001]; + size = a.length; + for(int index = 0; index < size; index++) { + a[index] = "hi"; + } + + for(int i=0; i psum(ArrayList v){ + int len = v.size(); + ArrayList ret = new ArrayList(len); + ret.add(0, v.get(0)); + for(int i=1; i v = new ArrayList(); + for (int i = 0; i < 1000000; i++) { + v.add(i); + } + + ArrayList vv = psum(v); + int ret; + for (int i = 0; i < 100000; i++) { + ret = vv.get(i+100000) - vv.get(i); + } + } +} diff --git a/green_pattern/patterns/prefix_sum/Before.jar b/green_pattern/patterns/prefix_sum/Before.jar new file mode 100644 index 0000000..3b305ba Binary files /dev/null and b/green_pattern/patterns/prefix_sum/Before.jar differ diff --git a/green_pattern/patterns/prefix_sum/Before.java b/green_pattern/patterns/prefix_sum/Before.java new file mode 100644 index 0000000..9fb49cd --- /dev/null +++ b/green_pattern/patterns/prefix_sum/Before.java @@ -0,0 +1,22 @@ +import java.util.ArrayList; + +public class Before { + public static int func(ArrayList v, int start, int end){ + int sum = 0; + for(int i=start; i v = new ArrayList(); + for (int i = 0; i < 1000000; i++) { + v.add(i); + } + + for (int i = 0; i < 100000; i++) { + func(v, i, i+100000); + } + } +} diff --git a/green_pattern/patterns/primitiveClass_to_WapperClass/After.java b/green_pattern/patterns/primitiveClass_to_WapperClass/After.java new file mode 100644 index 0000000..c323607 --- /dev/null +++ b/green_pattern/patterns/primitiveClass_to_WapperClass/After.java @@ -0,0 +1,10 @@ +public class After { + public static void main(String[] args) { + + int primitiveSum = 0; + for (int i = 0; i < 100000; i++) { + primitiveSum += i; + } + + } +} diff --git a/green_pattern/patterns/primitiveClass_to_WapperClass/Before.java b/green_pattern/patterns/primitiveClass_to_WapperClass/Before.java new file mode 100644 index 0000000..c21243d --- /dev/null +++ b/green_pattern/patterns/primitiveClass_to_WapperClass/Before.java @@ -0,0 +1,10 @@ +public class Before { + public static void main(String[] args) { + + Integer wrapperSum = 0; + for (int i = 0; i < 100000; i++) { + wrapperSum += i; + } + + } +} diff --git a/green_pattern/patterns/primitiveClass_to_WapperClass/after.jar b/green_pattern/patterns/primitiveClass_to_WapperClass/after.jar new file mode 100644 index 0000000..56d7132 Binary files /dev/null and b/green_pattern/patterns/primitiveClass_to_WapperClass/after.jar differ diff --git a/green_pattern/patterns/primitiveClass_to_WapperClass/before.jar b/green_pattern/patterns/primitiveClass_to_WapperClass/before.jar new file mode 100644 index 0000000..c67d454 Binary files /dev/null and b/green_pattern/patterns/primitiveClass_to_WapperClass/before.jar differ diff --git a/green_pattern/patterns/priority_queue/After.jar b/green_pattern/patterns/priority_queue/After.jar new file mode 100644 index 0000000..a866419 Binary files /dev/null and b/green_pattern/patterns/priority_queue/After.jar differ diff --git a/green_pattern/patterns/priority_queue/After.java b/green_pattern/patterns/priority_queue/After.java new file mode 100644 index 0000000..62e8bd3 --- /dev/null +++ b/green_pattern/patterns/priority_queue/After.java @@ -0,0 +1,27 @@ +import java.util.PriorityQueue; +import java.util.Collections; +import java.util.ArrayList; + +public class After { + public static void main(String[] args){ + ArrayList v = new ArrayList(); + PriorityQueue q = new PriorityQueue(Collections.reverseOrder()); + for(int i=0; i<10000000; i++){ + if(q.size() < 5){ + q.offer(i); + } + else{ + int curr = q.peek(); + if(i < curr){ + q.poll(); + q.offer(i); + } + } + } + + while(q.size() > 0){ + v.add(q.poll()); + } + Collections.reverse(v); + } +} diff --git a/green_pattern/patterns/priority_queue/Before.jar b/green_pattern/patterns/priority_queue/Before.jar new file mode 100644 index 0000000..fa63d3b Binary files /dev/null and b/green_pattern/patterns/priority_queue/Before.jar differ diff --git a/green_pattern/patterns/priority_queue/Before.java b/green_pattern/patterns/priority_queue/Before.java new file mode 100644 index 0000000..563a918 --- /dev/null +++ b/green_pattern/patterns/priority_queue/Before.java @@ -0,0 +1,18 @@ +import java.util.PriorityQueue; +import java.util.Collections; +import java.util.ArrayList; + +public class Before { + public static void main(String[] args){ + ArrayList v = new ArrayList(); + PriorityQueue q = new PriorityQueue(Collections.reverseOrder()); + for(int i=0; i<10000000; i++){ + q.offer(i); + } + + while(q.size() > 0){ + v.add(q.poll()); + } + Collections.reverse(v); + } +} diff --git a/green_pattern/patterns/regex_utilization/After.java b/green_pattern/patterns/regex_utilization/After.java new file mode 100644 index 0000000..d5e4d5f --- /dev/null +++ b/green_pattern/patterns/regex_utilization/After.java @@ -0,0 +1,24 @@ +public class After { + public static String findDomain(String email) { + int atPosition = -1; + for (int i = 0; i < email.length(); i++) { + if (email.charAt(i) == '@') { + atPosition = i; + break; + } + } + if (atPosition != -1) { + return email.substring(atPosition + 1); + } else { + return ""; + } + } + public static void main(String[] args){ + String email = "example.email@domain.com"; + + int iterations = 10000000; + for(int i=0; i 0) && (b > 0) && (c > 0)) { + // Do something + int t = a*b*c; + } + + + } + } +} diff --git a/green_pattern/patterns/short-circuit_evaluation/Before.java b/green_pattern/patterns/short-circuit_evaluation/Before.java new file mode 100644 index 0000000..d73e75e --- /dev/null +++ b/green_pattern/patterns/short-circuit_evaluation/Before.java @@ -0,0 +1,18 @@ +public class Before { + public static void main(String[] args) { + + for (int i = 0; i < 10000000; i++) { + + int a = -5; + int b = 10; + int c = 15; + + if ((a > 0) & (b > 0) & (c > 0)) { + // Do something + int t = a*b*c; + } + + } + + } +} diff --git a/green_pattern/patterns/short-circuit_evaluation/after.jar b/green_pattern/patterns/short-circuit_evaluation/after.jar new file mode 100644 index 0000000..347e7ba Binary files /dev/null and b/green_pattern/patterns/short-circuit_evaluation/after.jar differ diff --git a/green_pattern/patterns/short-circuit_evaluation/before.jar b/green_pattern/patterns/short-circuit_evaluation/before.jar new file mode 100644 index 0000000..072d844 Binary files /dev/null and b/green_pattern/patterns/short-circuit_evaluation/before.jar differ diff --git a/green_pattern/patterns/static_method_utilization/After.java b/green_pattern/patterns/static_method_utilization/After.java new file mode 100644 index 0000000..255c209 --- /dev/null +++ b/green_pattern/patterns/static_method_utilization/After.java @@ -0,0 +1,15 @@ +public class After { + private int value; + public After(int value) { + this.value = value; + } + public static int calculateSquare(int value) { + return value * value; + } + public static void main(String[] args) { + int iterations = 1000000; + for (int i = 0; i < iterations; i++) { + int result = calculateSquare(i); + } + } +} \ No newline at end of file diff --git a/green_pattern/patterns/static_method_utilization/Before.java b/green_pattern/patterns/static_method_utilization/Before.java new file mode 100644 index 0000000..37a06b6 --- /dev/null +++ b/green_pattern/patterns/static_method_utilization/Before.java @@ -0,0 +1,16 @@ +public class Before { + private int value; + public Before(int value) { + this.value = value; + } + public int calculateSquare() { + return value * value; + } + public static void main(String[] args) { + int iterations = 1000000; + for (int i = 0; i < iterations; i++) { + Before obj = new Before(i); + int result = obj.calculateSquare(); + } + } +} \ No newline at end of file diff --git a/green_pattern/patterns/static_method_utilization/after.jar b/green_pattern/patterns/static_method_utilization/after.jar new file mode 100644 index 0000000..1a585a8 Binary files /dev/null and b/green_pattern/patterns/static_method_utilization/after.jar differ diff --git a/green_pattern/patterns/static_method_utilization/before.jar b/green_pattern/patterns/static_method_utilization/before.jar new file mode 100644 index 0000000..036bee0 Binary files /dev/null and b/green_pattern/patterns/static_method_utilization/before.jar differ diff --git a/green_pattern/patterns/static_variable_utilization/After.java b/green_pattern/patterns/static_variable_utilization/After.java new file mode 100644 index 0000000..0c2fdfa --- /dev/null +++ b/green_pattern/patterns/static_variable_utilization/After.java @@ -0,0 +1,14 @@ +public class After { + static int[] a = new int[10000000]; + private static int func1(){ + a[0] = 10; + return a[0]; + } + public static void main(String[] args){ + int iterations = 1000; + + for(int i=0; i result1 = executorService.submit(() -> calculateSum(1, 200000)); + Future result2 = executorService.submit(() -> calculateSum(200001, 4000000)); + Future result3 = executorService.submit(() -> calculateSum(400001, 6000000)); + Future result4 = executorService.submit(() -> calculateSum(600001, 8000000)); + Future result5 = executorService.submit(() -> calculateSum(800001, 10000000)); + + + int iterations = 1000; + try { + for (int i=0; i v, int target){ + int len = v.size(); + int left = 0; + int right = len-1; + while(left != right){ + int sum = v.get(left) + v.get(right); + if(sum == target){ + return true; + } + else if(sum < target){ + left++; + } + else{ + right--; + } + } + return false; + } + + public static void main(String[] args){ + long begin = System.currentTimeMillis(); + + ArrayList v = new ArrayList(); + for (int i = 0; i < 10000; i++) { + v.add(i); + } + + for (int i = 0; i < 10000; i++) { + func(v, i); + } + + long dur = System.currentTimeMillis() - begin; + System.out.println("Execution Time: " + dur/1000.0 + " seconds"); + } +} diff --git a/green_pattern/patterns/two_pointer/Before.jar b/green_pattern/patterns/two_pointer/Before.jar new file mode 100644 index 0000000..eb0f80b Binary files /dev/null and b/green_pattern/patterns/two_pointer/Before.jar differ diff --git a/green_pattern/patterns/two_pointer/Before.java b/green_pattern/patterns/two_pointer/Before.java new file mode 100644 index 0000000..beaa406 --- /dev/null +++ b/green_pattern/patterns/two_pointer/Before.java @@ -0,0 +1,26 @@ +import java.util.ArrayList; + +public class Before { + public static boolean func(ArrayList v, int target){ + int len = v.size(); + for(int i=0; i v = new ArrayList(); + for (int i = 0; i < 10000; i++) { + v.add(i); + } + + for (int i = 0; i < 10000; i++) { + func(v, i); + } + } +} diff --git a/green_pattern/patterns/unnecessary_float/After.java b/green_pattern/patterns/unnecessary_float/After.java new file mode 100644 index 0000000..0bdeca0 --- /dev/null +++ b/green_pattern/patterns/unnecessary_float/After.java @@ -0,0 +1,18 @@ +public class After { + public static void main(String[] args){ + int iterations = 100000; + + double test= 100 / 3; + int output = 0; + for (int i = 0; i < iterations; i++) { + for (int j = 0; j < iterations; j++) { + double res = test + 30.0; + double res2 = res + 50.0; + if(res2 > 100.0){ + res2 += 90.0; + } + output += (int)res2; + } + } + } +} \ No newline at end of file diff --git a/green_pattern/patterns/unnecessary_float/Before.java b/green_pattern/patterns/unnecessary_float/Before.java new file mode 100644 index 0000000..9bbb000 --- /dev/null +++ b/green_pattern/patterns/unnecessary_float/Before.java @@ -0,0 +1,18 @@ +public class Before { + public static void main(String[] args){ + int iterations = 100000; + + double test= 100 / 3; + int output = 0; + for (int i = 0; i < iterations; i++) { + for (int j = 0; j < iterations; j++) { + int res = (int)test + 30; + int res2 = res + 50; + if(res2 > 100){ + res2 += 90; + } + output += (int)res2; + } + } + } +} \ No newline at end of file diff --git a/green_pattern/patterns/unnecessary_float/after.jar b/green_pattern/patterns/unnecessary_float/after.jar new file mode 100644 index 0000000..2257c51 Binary files /dev/null and b/green_pattern/patterns/unnecessary_float/after.jar differ diff --git a/green_pattern/patterns/unnecessary_float/before.jar b/green_pattern/patterns/unnecessary_float/before.jar new file mode 100644 index 0000000..e4cd36b Binary files /dev/null and b/green_pattern/patterns/unnecessary_float/before.jar differ diff --git a/green_pattern/patterns/unnecessary_parameter/After.java b/green_pattern/patterns/unnecessary_parameter/After.java new file mode 100644 index 0000000..4985912 --- /dev/null +++ b/green_pattern/patterns/unnecessary_parameter/After.java @@ -0,0 +1,17 @@ + public class After { + public static void main(String[] args) { + int iterations = 1000000; + int[] numbers = {1, 2, 3, 4, 5}; + for (int k = 0; k < iterations; k++ ){ + calculateSum(numbers); + } + } + + private static int calculateSum(int[] array) { + int sum = 0; + for (int i = 0; i < array.length; i++) { + sum += array[i]; + } + return sum; + } +} \ No newline at end of file diff --git a/green_pattern/patterns/unnecessary_parameter/Before.java b/green_pattern/patterns/unnecessary_parameter/Before.java new file mode 100644 index 0000000..6112a3f --- /dev/null +++ b/green_pattern/patterns/unnecessary_parameter/Before.java @@ -0,0 +1,17 @@ + public class Before { + public static void main(String[] args) { + int iterations = 1000000; + int[] numbers = {1, 2, 3, 4, 5}; + for (int k = 0; k < iterations; k++ ){ + calculateSum(numbers, numbers.length); + } + } + + private static int calculateSum(int[] array, int length) { + int sum = 0; + for (int i = 0; i < length; i++) { + sum += array[i]; + } + return sum; + } +} \ No newline at end of file diff --git a/green_pattern/patterns/unnecessary_parameter/after.jar b/green_pattern/patterns/unnecessary_parameter/after.jar new file mode 100644 index 0000000..bd234e6 Binary files /dev/null and b/green_pattern/patterns/unnecessary_parameter/after.jar differ diff --git a/green_pattern/patterns/unnecessary_parameter/before.jar b/green_pattern/patterns/unnecessary_parameter/before.jar new file mode 100644 index 0000000..88825e5 Binary files /dev/null and b/green_pattern/patterns/unnecessary_parameter/before.jar differ diff --git a/green_pattern/patterns/use_buffer_when_copy_file/After.java b/green_pattern/patterns/use_buffer_when_copy_file/After.java new file mode 100644 index 0000000..ae84faf --- /dev/null +++ b/green_pattern/patterns/use_buffer_when_copy_file/After.java @@ -0,0 +1,24 @@ +import java.io.*; + +public class After { + + public static void main(String[] args) { + try { + InputStream inputStream = After.class.getResourceAsStream("/input.txt"); + + BufferedInputStream in = new BufferedInputStream(inputStream); + BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("output.txt")); + byte[] buffer = new byte[8192]; + int length; + + while ((length = in.read(buffer)) > 0) { + out.write(buffer, 0, length); + } + + in.close(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/green_pattern/patterns/use_buffer_when_copy_file/Before.java b/green_pattern/patterns/use_buffer_when_copy_file/Before.java new file mode 100644 index 0000000..5143efd --- /dev/null +++ b/green_pattern/patterns/use_buffer_when_copy_file/Before.java @@ -0,0 +1,23 @@ +import java.io.*; + +public class Before { + + public static void main(String[] args) { + try { + InputStream inputStream = Before.class.getResourceAsStream("input.txt"); + + BufferedInputStream in = new BufferedInputStream(inputStream); + FileOutputStream out = new FileOutputStream("output.txt"); + int c; + + while ((c = in.read()) != -1) { + out.write(c); + } + + in.close(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/green_pattern/patterns/use_buffer_when_copy_file/after.jar b/green_pattern/patterns/use_buffer_when_copy_file/after.jar new file mode 100644 index 0000000..f4bef3b Binary files /dev/null and b/green_pattern/patterns/use_buffer_when_copy_file/after.jar differ diff --git a/green_pattern/patterns/use_buffer_when_copy_file/before.jar b/green_pattern/patterns/use_buffer_when_copy_file/before.jar new file mode 100644 index 0000000..49352e2 Binary files /dev/null and b/green_pattern/patterns/use_buffer_when_copy_file/before.jar differ diff --git a/green_pattern/patterns/use_buffer_when_copy_file/input.txt b/green_pattern/patterns/use_buffer_when_copy_file/input.txt new file mode 100644 index 0000000..386c4cf --- /dev/null +++ b/green_pattern/patterns/use_buffer_when_copy_file/input.txt @@ -0,0 +1 @@ +lorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy siro \ No newline at end of file diff --git a/green_pattern/patterns/use_buffer_when_copy_file/output.txt b/green_pattern/patterns/use_buffer_when_copy_file/output.txt new file mode 100644 index 0000000..386c4cf --- /dev/null +++ b/green_pattern/patterns/use_buffer_when_copy_file/output.txt @@ -0,0 +1 @@ +lorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy sirolorem ipsum hagy silta jincha hagy siro \ No newline at end of file diff --git a/green_pattern/patterns/use_decimal_format/After.java b/green_pattern/patterns/use_decimal_format/After.java new file mode 100644 index 0000000..2bbcb43 --- /dev/null +++ b/green_pattern/patterns/use_decimal_format/After.java @@ -0,0 +1,11 @@ +import java.text.DecimalFormat; + +public class After { + public static void main(String[] args){ + DecimalFormat df = new DecimalFormat("#,###"); + int iterations = 1000000; + for(int i=0 ; i python ./submitOne.py {yourPatternName} + +============================================= + +다른 파이썬 파일들 (신경안쓰셔도 됩니다!!) + +0. testOnePattern.py: patterns/ 폴더에 있는 하나의 패턴 테스트 +usage: python ./testOnePattern.py {yourPatternName} + +1. compileAll.py : patterns/ 폴더에 있는 모든 패턴 컴파일 +2. compressAll.py : patterns/ 폴더에 있는 모든 패턴 압축 (.jar) +3. evaluteAll.py : patterns/ 폴더에 있는 모든 jar 파일 테스트 +4. submitAll.py : patterns/ 폴더에 있는 모든 jar 파일 submission/ 폴더로 이동 + +5. checkSubmission.py: submission/ 폴더에 있는 모든 jar 파일 테스트 \ No newline at end of file diff --git a/green_pattern/submission/after_1.jar b/green_pattern/submission/after_1.jar new file mode 100644 index 0000000..7e8e292 Binary files /dev/null and b/green_pattern/submission/after_1.jar differ diff --git a/green_pattern/submission/after_10.jar b/green_pattern/submission/after_10.jar new file mode 100644 index 0000000..1a585a8 Binary files /dev/null and b/green_pattern/submission/after_10.jar differ diff --git a/green_pattern/submission/after_11.jar b/green_pattern/submission/after_11.jar new file mode 100644 index 0000000..be4f9a2 Binary files /dev/null and b/green_pattern/submission/after_11.jar differ diff --git a/green_pattern/submission/after_12.jar b/green_pattern/submission/after_12.jar new file mode 100644 index 0000000..e391d7f Binary files /dev/null and b/green_pattern/submission/after_12.jar differ diff --git a/green_pattern/submission/after_13.jar b/green_pattern/submission/after_13.jar new file mode 100644 index 0000000..b717350 Binary files /dev/null and b/green_pattern/submission/after_13.jar differ diff --git a/green_pattern/submission/after_14.jar b/green_pattern/submission/after_14.jar new file mode 100644 index 0000000..608446b Binary files /dev/null and b/green_pattern/submission/after_14.jar differ diff --git a/green_pattern/submission/after_15.jar b/green_pattern/submission/after_15.jar new file mode 100644 index 0000000..bfe9aa8 Binary files /dev/null and b/green_pattern/submission/after_15.jar differ diff --git a/green_pattern/submission/after_16.jar b/green_pattern/submission/after_16.jar new file mode 100644 index 0000000..8d0b9f4 Binary files /dev/null and b/green_pattern/submission/after_16.jar differ diff --git a/green_pattern/submission/after_17.jar b/green_pattern/submission/after_17.jar new file mode 100644 index 0000000..1a8dd3f Binary files /dev/null and b/green_pattern/submission/after_17.jar differ diff --git a/green_pattern/submission/after_18.jar b/green_pattern/submission/after_18.jar new file mode 100644 index 0000000..0174d3a Binary files /dev/null and b/green_pattern/submission/after_18.jar differ diff --git a/green_pattern/submission/after_19.jar b/green_pattern/submission/after_19.jar new file mode 100644 index 0000000..901d552 Binary files /dev/null and b/green_pattern/submission/after_19.jar differ diff --git a/green_pattern/submission/after_2.jar b/green_pattern/submission/after_2.jar new file mode 100644 index 0000000..a866419 Binary files /dev/null and b/green_pattern/submission/after_2.jar differ diff --git a/green_pattern/submission/after_20.jar b/green_pattern/submission/after_20.jar new file mode 100644 index 0000000..01b0124 Binary files /dev/null and b/green_pattern/submission/after_20.jar differ diff --git a/green_pattern/submission/after_21.jar b/green_pattern/submission/after_21.jar new file mode 100644 index 0000000..7c62653 Binary files /dev/null and b/green_pattern/submission/after_21.jar differ diff --git a/green_pattern/submission/after_22.jar b/green_pattern/submission/after_22.jar new file mode 100644 index 0000000..9a944a4 Binary files /dev/null and b/green_pattern/submission/after_22.jar differ diff --git a/green_pattern/submission/after_23.jar b/green_pattern/submission/after_23.jar new file mode 100644 index 0000000..d41a3da Binary files /dev/null and b/green_pattern/submission/after_23.jar differ diff --git a/green_pattern/submission/after_24.jar b/green_pattern/submission/after_24.jar new file mode 100644 index 0000000..9e7594f Binary files /dev/null and b/green_pattern/submission/after_24.jar differ diff --git a/green_pattern/submission/after_25.jar b/green_pattern/submission/after_25.jar new file mode 100644 index 0000000..b22e7ce Binary files /dev/null and b/green_pattern/submission/after_25.jar differ diff --git a/green_pattern/submission/after_26.jar b/green_pattern/submission/after_26.jar new file mode 100644 index 0000000..f1cd316 Binary files /dev/null and b/green_pattern/submission/after_26.jar differ diff --git a/green_pattern/submission/after_27.jar b/green_pattern/submission/after_27.jar new file mode 100644 index 0000000..adfe52b Binary files /dev/null and b/green_pattern/submission/after_27.jar differ diff --git a/green_pattern/submission/after_28.jar b/green_pattern/submission/after_28.jar new file mode 100644 index 0000000..eba0529 Binary files /dev/null and b/green_pattern/submission/after_28.jar differ diff --git a/green_pattern/submission/after_29.jar b/green_pattern/submission/after_29.jar new file mode 100644 index 0000000..702d105 Binary files /dev/null and b/green_pattern/submission/after_29.jar differ diff --git a/green_pattern/submission/after_3.jar b/green_pattern/submission/after_3.jar new file mode 100644 index 0000000..9fa2dfc Binary files /dev/null and b/green_pattern/submission/after_3.jar differ diff --git a/green_pattern/submission/after_30.jar b/green_pattern/submission/after_30.jar new file mode 100644 index 0000000..f69306f Binary files /dev/null and b/green_pattern/submission/after_30.jar differ diff --git a/green_pattern/submission/after_31.jar b/green_pattern/submission/after_31.jar new file mode 100644 index 0000000..7c4bbf2 Binary files /dev/null and b/green_pattern/submission/after_31.jar differ diff --git a/green_pattern/submission/after_32.jar b/green_pattern/submission/after_32.jar new file mode 100644 index 0000000..eaba127 Binary files /dev/null and b/green_pattern/submission/after_32.jar differ diff --git a/green_pattern/submission/after_33.jar b/green_pattern/submission/after_33.jar new file mode 100644 index 0000000..445baae Binary files /dev/null and b/green_pattern/submission/after_33.jar differ diff --git a/green_pattern/submission/after_34.jar b/green_pattern/submission/after_34.jar new file mode 100644 index 0000000..184f1c3 Binary files /dev/null and b/green_pattern/submission/after_34.jar differ diff --git a/green_pattern/submission/after_35.jar b/green_pattern/submission/after_35.jar new file mode 100644 index 0000000..b20593e Binary files /dev/null and b/green_pattern/submission/after_35.jar differ diff --git a/green_pattern/submission/after_36.jar b/green_pattern/submission/after_36.jar new file mode 100644 index 0000000..2257c51 Binary files /dev/null and b/green_pattern/submission/after_36.jar differ diff --git a/green_pattern/submission/after_37.jar b/green_pattern/submission/after_37.jar new file mode 100644 index 0000000..ae781ae Binary files /dev/null and b/green_pattern/submission/after_37.jar differ diff --git a/green_pattern/submission/after_38.jar b/green_pattern/submission/after_38.jar new file mode 100644 index 0000000..16cd280 Binary files /dev/null and b/green_pattern/submission/after_38.jar differ diff --git a/green_pattern/submission/after_39.jar b/green_pattern/submission/after_39.jar new file mode 100644 index 0000000..16b5ecc Binary files /dev/null and b/green_pattern/submission/after_39.jar differ diff --git a/green_pattern/submission/after_4.jar b/green_pattern/submission/after_4.jar new file mode 100644 index 0000000..c2b6240 Binary files /dev/null and b/green_pattern/submission/after_4.jar differ diff --git a/green_pattern/submission/after_40.jar b/green_pattern/submission/after_40.jar new file mode 100644 index 0000000..fe41f7c Binary files /dev/null and b/green_pattern/submission/after_40.jar differ diff --git a/green_pattern/submission/after_41.jar b/green_pattern/submission/after_41.jar new file mode 100644 index 0000000..39586f6 Binary files /dev/null and b/green_pattern/submission/after_41.jar differ diff --git a/green_pattern/submission/after_42.jar b/green_pattern/submission/after_42.jar new file mode 100644 index 0000000..ae660f0 Binary files /dev/null and b/green_pattern/submission/after_42.jar differ diff --git a/green_pattern/submission/after_43.jar b/green_pattern/submission/after_43.jar new file mode 100644 index 0000000..a295659 Binary files /dev/null and b/green_pattern/submission/after_43.jar differ diff --git a/green_pattern/submission/after_44.jar b/green_pattern/submission/after_44.jar new file mode 100644 index 0000000..bd234e6 Binary files /dev/null and b/green_pattern/submission/after_44.jar differ diff --git a/green_pattern/submission/after_5.jar b/green_pattern/submission/after_5.jar new file mode 100644 index 0000000..aa100e7 Binary files /dev/null and b/green_pattern/submission/after_5.jar differ diff --git a/green_pattern/submission/after_6.jar b/green_pattern/submission/after_6.jar new file mode 100644 index 0000000..f4bef3b Binary files /dev/null and b/green_pattern/submission/after_6.jar differ diff --git a/green_pattern/submission/after_7.jar b/green_pattern/submission/after_7.jar new file mode 100644 index 0000000..e46c583 Binary files /dev/null and b/green_pattern/submission/after_7.jar differ diff --git a/green_pattern/submission/after_8.jar b/green_pattern/submission/after_8.jar new file mode 100644 index 0000000..bd8fa79 Binary files /dev/null and b/green_pattern/submission/after_8.jar differ diff --git a/green_pattern/submission/after_9.jar b/green_pattern/submission/after_9.jar new file mode 100644 index 0000000..ba413f2 Binary files /dev/null and b/green_pattern/submission/after_9.jar differ diff --git a/green_pattern/submission/before_1.jar b/green_pattern/submission/before_1.jar new file mode 100644 index 0000000..73101fd Binary files /dev/null and b/green_pattern/submission/before_1.jar differ diff --git a/green_pattern/submission/before_10.jar b/green_pattern/submission/before_10.jar new file mode 100644 index 0000000..036bee0 Binary files /dev/null and b/green_pattern/submission/before_10.jar differ diff --git a/green_pattern/submission/before_11.jar b/green_pattern/submission/before_11.jar new file mode 100644 index 0000000..0e09338 Binary files /dev/null and b/green_pattern/submission/before_11.jar differ diff --git a/green_pattern/submission/before_12.jar b/green_pattern/submission/before_12.jar new file mode 100644 index 0000000..9b9b97b Binary files /dev/null and b/green_pattern/submission/before_12.jar differ diff --git a/green_pattern/submission/before_13.jar b/green_pattern/submission/before_13.jar new file mode 100644 index 0000000..0c6da6d Binary files /dev/null and b/green_pattern/submission/before_13.jar differ diff --git a/green_pattern/submission/before_14.jar b/green_pattern/submission/before_14.jar new file mode 100644 index 0000000..3b305ba Binary files /dev/null and b/green_pattern/submission/before_14.jar differ diff --git a/green_pattern/submission/before_15.jar b/green_pattern/submission/before_15.jar new file mode 100644 index 0000000..eb0f80b Binary files /dev/null and b/green_pattern/submission/before_15.jar differ diff --git a/green_pattern/submission/before_16.jar b/green_pattern/submission/before_16.jar new file mode 100644 index 0000000..6df3d82 Binary files /dev/null and b/green_pattern/submission/before_16.jar differ diff --git a/green_pattern/submission/before_17.jar b/green_pattern/submission/before_17.jar new file mode 100644 index 0000000..550b21d Binary files /dev/null and b/green_pattern/submission/before_17.jar differ diff --git a/green_pattern/submission/before_18.jar b/green_pattern/submission/before_18.jar new file mode 100644 index 0000000..2d6b960 Binary files /dev/null and b/green_pattern/submission/before_18.jar differ diff --git a/green_pattern/submission/before_19.jar b/green_pattern/submission/before_19.jar new file mode 100644 index 0000000..ddf0335 Binary files /dev/null and b/green_pattern/submission/before_19.jar differ diff --git a/green_pattern/submission/before_2.jar b/green_pattern/submission/before_2.jar new file mode 100644 index 0000000..fa63d3b Binary files /dev/null and b/green_pattern/submission/before_2.jar differ diff --git a/green_pattern/submission/before_20.jar b/green_pattern/submission/before_20.jar new file mode 100644 index 0000000..8c02f46 Binary files /dev/null and b/green_pattern/submission/before_20.jar differ diff --git a/green_pattern/submission/before_21.jar b/green_pattern/submission/before_21.jar new file mode 100644 index 0000000..880abcd Binary files /dev/null and b/green_pattern/submission/before_21.jar differ diff --git a/green_pattern/submission/before_22.jar b/green_pattern/submission/before_22.jar new file mode 100644 index 0000000..0a24302 Binary files /dev/null and b/green_pattern/submission/before_22.jar differ diff --git a/green_pattern/submission/before_23.jar b/green_pattern/submission/before_23.jar new file mode 100644 index 0000000..f74a854 Binary files /dev/null and b/green_pattern/submission/before_23.jar differ diff --git a/green_pattern/submission/before_24.jar b/green_pattern/submission/before_24.jar new file mode 100644 index 0000000..8728f6c Binary files /dev/null and b/green_pattern/submission/before_24.jar differ diff --git a/green_pattern/submission/before_25.jar b/green_pattern/submission/before_25.jar new file mode 100644 index 0000000..560cbef Binary files /dev/null and b/green_pattern/submission/before_25.jar differ diff --git a/green_pattern/submission/before_26.jar b/green_pattern/submission/before_26.jar new file mode 100644 index 0000000..a2e993c Binary files /dev/null and b/green_pattern/submission/before_26.jar differ diff --git a/green_pattern/submission/before_27.jar b/green_pattern/submission/before_27.jar new file mode 100644 index 0000000..96afc09 Binary files /dev/null and b/green_pattern/submission/before_27.jar differ diff --git a/green_pattern/submission/before_28.jar b/green_pattern/submission/before_28.jar new file mode 100644 index 0000000..7869d93 Binary files /dev/null and b/green_pattern/submission/before_28.jar differ diff --git a/green_pattern/submission/before_29.jar b/green_pattern/submission/before_29.jar new file mode 100644 index 0000000..b1c7740 Binary files /dev/null and b/green_pattern/submission/before_29.jar differ diff --git a/green_pattern/submission/before_3.jar b/green_pattern/submission/before_3.jar new file mode 100644 index 0000000..c1161c2 Binary files /dev/null and b/green_pattern/submission/before_3.jar differ diff --git a/green_pattern/submission/before_30.jar b/green_pattern/submission/before_30.jar new file mode 100644 index 0000000..e112b61 Binary files /dev/null and b/green_pattern/submission/before_30.jar differ diff --git a/green_pattern/submission/before_31.jar b/green_pattern/submission/before_31.jar new file mode 100644 index 0000000..155e899 Binary files /dev/null and b/green_pattern/submission/before_31.jar differ diff --git a/green_pattern/submission/before_32.jar b/green_pattern/submission/before_32.jar new file mode 100644 index 0000000..82122e1 Binary files /dev/null and b/green_pattern/submission/before_32.jar differ diff --git a/green_pattern/submission/before_33.jar b/green_pattern/submission/before_33.jar new file mode 100644 index 0000000..a20ca35 Binary files /dev/null and b/green_pattern/submission/before_33.jar differ diff --git a/green_pattern/submission/before_34.jar b/green_pattern/submission/before_34.jar new file mode 100644 index 0000000..0ea798c Binary files /dev/null and b/green_pattern/submission/before_34.jar differ diff --git a/green_pattern/submission/before_35.jar b/green_pattern/submission/before_35.jar new file mode 100644 index 0000000..46f2aed Binary files /dev/null and b/green_pattern/submission/before_35.jar differ diff --git a/green_pattern/submission/before_36.jar b/green_pattern/submission/before_36.jar new file mode 100644 index 0000000..e4cd36b Binary files /dev/null and b/green_pattern/submission/before_36.jar differ diff --git a/green_pattern/submission/before_37.jar b/green_pattern/submission/before_37.jar new file mode 100644 index 0000000..b747814 Binary files /dev/null and b/green_pattern/submission/before_37.jar differ diff --git a/green_pattern/submission/before_38.jar b/green_pattern/submission/before_38.jar new file mode 100644 index 0000000..458c37d Binary files /dev/null and b/green_pattern/submission/before_38.jar differ diff --git a/green_pattern/submission/before_39.jar b/green_pattern/submission/before_39.jar new file mode 100644 index 0000000..314052b Binary files /dev/null and b/green_pattern/submission/before_39.jar differ diff --git a/green_pattern/submission/before_4.jar b/green_pattern/submission/before_4.jar new file mode 100644 index 0000000..c75fe0d Binary files /dev/null and b/green_pattern/submission/before_4.jar differ diff --git a/green_pattern/submission/before_40.jar b/green_pattern/submission/before_40.jar new file mode 100644 index 0000000..465e54c Binary files /dev/null and b/green_pattern/submission/before_40.jar differ diff --git a/green_pattern/submission/before_41.jar b/green_pattern/submission/before_41.jar new file mode 100644 index 0000000..8befd2a Binary files /dev/null and b/green_pattern/submission/before_41.jar differ diff --git a/green_pattern/submission/before_42.jar b/green_pattern/submission/before_42.jar new file mode 100644 index 0000000..208cc81 Binary files /dev/null and b/green_pattern/submission/before_42.jar differ diff --git a/green_pattern/submission/before_43.jar b/green_pattern/submission/before_43.jar new file mode 100644 index 0000000..5eb63a7 Binary files /dev/null and b/green_pattern/submission/before_43.jar differ diff --git a/green_pattern/submission/before_44.jar b/green_pattern/submission/before_44.jar new file mode 100644 index 0000000..88825e5 Binary files /dev/null and b/green_pattern/submission/before_44.jar differ diff --git a/green_pattern/submission/before_5.jar b/green_pattern/submission/before_5.jar new file mode 100644 index 0000000..d7d8316 Binary files /dev/null and b/green_pattern/submission/before_5.jar differ diff --git a/green_pattern/submission/before_6.jar b/green_pattern/submission/before_6.jar new file mode 100644 index 0000000..49352e2 Binary files /dev/null and b/green_pattern/submission/before_6.jar differ diff --git a/green_pattern/submission/before_7.jar b/green_pattern/submission/before_7.jar new file mode 100644 index 0000000..cdaa2b5 Binary files /dev/null and b/green_pattern/submission/before_7.jar differ diff --git a/green_pattern/submission/before_8.jar b/green_pattern/submission/before_8.jar new file mode 100644 index 0000000..1f6a5fe Binary files /dev/null and b/green_pattern/submission/before_8.jar differ diff --git a/green_pattern/submission/before_9.jar b/green_pattern/submission/before_9.jar new file mode 100644 index 0000000..48fb162 Binary files /dev/null and b/green_pattern/submission/before_9.jar differ diff --git a/green_pattern/submitAll.py b/green_pattern/submitAll.py new file mode 100644 index 0000000..8b9544f --- /dev/null +++ b/green_pattern/submitAll.py @@ -0,0 +1,55 @@ + +import time +import subprocess +import warnings + + +from os import listdir +from os.path import isfile, join + +patterns = [f for f in listdir("./patterns") if not isfile(join("./patterns/", f))] +for dir_name in patterns: + # measure Before.java execution time + execution_result = subprocess.run(["copy", r".\after.jar", r"..\..\submission"], capture_output=True, cwd=f'./patterns/{dir_name}', shell=True) + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + + # measure After.java execution time + execution_result = subprocess.run(["copy", ".\\before.jar", f"..\\..\\submission"], capture_output=True, cwd=f'./patterns/{dir_name}', shell=True) + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + + +# measure Before.java execution time + execution_result = subprocess.run(["ren", "after.jar", f"after_{dir_name}.jar"], capture_output=True, cwd=f'./submission', shell=True) + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + + # measure After.java execution time + execution_result = subprocess.run(["ren", "before.jar", f"before_{dir_name}.jar"], capture_output=True, cwd=f'./submission', shell=True) + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) \ No newline at end of file diff --git a/green_pattern/submitOne.py b/green_pattern/submitOne.py new file mode 100644 index 0000000..b7f57e3 --- /dev/null +++ b/green_pattern/submitOne.py @@ -0,0 +1,137 @@ +import subprocess +import sys +from os import listdir +from os.path import isfile, join +import time + +if len(sys.argv) < 2: + print("please input dir_name.") + exit(1) + +dir_name = sys.argv[1] + +bef_compilation_result = subprocess.run(["javac", "Before.java"], capture_output=True, cwd=f'./patterns/{dir_name}') +aft_compilation_result = subprocess.run(["javac", "After.java" ], capture_output=True, cwd=f'./patterns/{dir_name}') +try: + bef_compilation_result.check_returncode() + aft_compilation_result.check_returncode() +except subprocess.CalledProcessError as err: + bef_raw_err = bef_compilation_result.stderr + aft_raw_err = aft_compilation_result.stderr + err = bef_raw_err.decode("unicode_escape").strip() + "\n" + aft_raw_err.decode("unicode_escape").strip() + print(err) + exit(0) + +srcfiles = listdir(f"./patterns/{dir_name}") + +rmfiles = ["After.java", "Before.java", "After.class", "Before.class", "after.jar", "before.jar"] +for file in rmfiles: + if file in srcfiles: + srcfiles.remove(file) + +bef_compression_result = subprocess.run(["jar", "cfe", "before.jar", "Before", "Before.class", *srcfiles], capture_output=True, cwd=f'./patterns/{dir_name}') +aft_compression_result = subprocess.run(["jar", "cfe", "after.jar", "After", "After.class", *srcfiles], capture_output=True, cwd=f'./patterns/{dir_name}') +try: + bef_compression_result.check_returncode() + aft_compression_result.check_returncode() +except subprocess.CalledProcessError as err: + bef_raw_err = bef_compression_result.stderr + aft_raw_err = aft_compression_result.stderr + err = bef_raw_err.decode("unicode_escape").strip() + "\n" + aft_raw_err.decode("unicode_escape").strip() + print(err) + exit(0) + + +# measure Before.java execution time +bef_execution_time = 0 +start_time = time.perf_counter() +execution_result = subprocess.run(["java", "-jar", "before.jar"], capture_output=True, cwd=f'./patterns/{dir_name}') +bef_execution_time += (time.perf_counter()-start_time) +try: + execution_result.check_returncode() +except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + +# measure After.java execution time +aft_execution_time = 0 +start_time = time.perf_counter() +execution_result = subprocess.run(["java", "-jar", "after.jar"], capture_output=True, cwd=f'./patterns/{dir_name}') +aft_execution_time += (time.perf_counter()-start_time) +try: + execution_result.check_returncode() +except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + +print(f"============= Result ({dir_name}) =============") +print(f"[Before.jar] runtime: {bef_execution_time:0.4f}s") +print(f"[After.jar ] runtime: {aft_execution_time:0.4f}s") +if bef_execution_time > aft_execution_time: + print(f"=> runtime decreased by {bef_execution_time-aft_execution_time:0.4f}s") +else: + print("=> runtime has not decreased...") + +# measure Before.java execution time +execution_result = subprocess.run(["copy", r".\after.jar", r"..\..\submission"], capture_output=True, cwd=f'./patterns/{dir_name}', shell=True) +try: + execution_result.check_returncode() +except subprocess.CalledProcessError as err: + print(f"copy jar from patterns/{dir_name}to submissions/ failed") + print("===> saving as .jar failed") + exit(0) + +# measure After.java execution time +execution_result = subprocess.run(["copy", ".\\before.jar", f"..\\..\\submission"], capture_output=True, cwd=f'./patterns/{dir_name}', shell=True) +try: + execution_result.check_returncode() +except subprocess.CalledProcessError as err: + print(f"copy jar from patterns/{dir_name}to submissions/ failed") + print("===> saving as .jar failed") + exit(0) + + +subfiles = listdir("./submission") +if f"after_{dir_name}.jar" in subfiles: + execution_result = subprocess.run(["del", f"after_{dir_name}.jar"], capture_output=True, cwd=f'./submission', shell=True) + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + print("remove previous jar failed") + print("===> saving as .jar failed") + exit(0) + +if f"before_{dir_name}.jar" in subfiles: + execution_result = subprocess.run(["del", f"before_{dir_name}.jar"], capture_output=True, cwd=f'./submission', shell=True) + try: + execution_result.check_returncode() + except subprocess.CalledProcessError as err: + print("remove previous jar failed") + print("===> saving as .jar failed") + exit(0) + +execution_result = subprocess.run(["ren", "after.jar", f"after_{dir_name}.jar"], capture_output=True, cwd=f'./submission', shell=True) +try: + execution_result.check_returncode() +except subprocess.CalledProcessError as err: + print("rename failed") + print("===> saving as .jar failed") + exit(0) + +execution_result = subprocess.run(["ren", "before.jar", f"before_{dir_name}.jar"], capture_output=True, cwd=f'./submission', shell=True) +try: + execution_result.check_returncode() +except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print("rename failed") + print("===> saving as .jar failed") + exit(0) + +print("===> succefully saved as .jar") \ No newline at end of file diff --git a/green_pattern/testOnePattern.py b/green_pattern/testOnePattern.py new file mode 100644 index 0000000..1b2738e --- /dev/null +++ b/green_pattern/testOnePattern.py @@ -0,0 +1,70 @@ +import time +import sys +import subprocess +import warnings + +warnings.filterwarnings("ignore", category=DeprecationWarning) + +# ##################### USAGE ####################### # +# # +# > python ./measurePattern.py [dir name] # +# # +# ################################################### # + + +if len(sys.argv) < 2: + print("please input dir_name.") + exit(1) + +dir_name = sys.argv[1] + + +# compile Before.java and After.java +bef_compilation_result = subprocess.run(["javac", "Before.java"], capture_output=True, cwd=f'./patterns/{dir_name}') +aft_compilation_result = subprocess.run(["javac", "After.java" ], capture_output=True, cwd=f'./patterns/{dir_name}') +try: + bef_compilation_result.check_returncode() + aft_compilation_result.check_returncode() +except subprocess.CalledProcessError as err: + bef_raw_err = bef_compilation_result.stderr + aft_raw_err = aft_compilation_result.stderr + err = bef_raw_err.decode("unicode_escape").strip() + "\n" + aft_raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + + +# measure Before.java execution time +bef_execution_time = 0 +start_time = time.perf_counter() +execution_result = subprocess.run(["java", "Before"], capture_output=True, cwd=f'./patterns/{dir_name}') +bef_execution_time = (time.perf_counter()-start_time) +try: + execution_result.check_returncode() +except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + # some other error handlings + exit(0) + +# measure After.java execution time +aft_execution_time = 0 +start_time = time.perf_counter() +execution_result = subprocess.run(["java", "After"], capture_output=True, cwd=f'./patterns/{dir_name}') +aft_execution_time = (time.perf_counter()-start_time) +try: + execution_result.check_returncode() +except subprocess.CalledProcessError as err: + raw_err = execution_result.stderr + err = raw_err.decode("unicode_escape").strip() + print(err) + exit(0) + +print(f"============= Result ({dir_name}) =============") +print(f"[Before.java] avg runtime: {bef_execution_time:0.4f}s") +print(f"[After.java ] avg runtime: {aft_execution_time:0.4f}s") +if bef_execution_time > aft_execution_time: + print(f"=> runtime decreased by {bef_execution_time-aft_execution_time:0.4f}s") +else: + print("=> runtime has not decreased...")