Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Analyzer {
- public static void runAllAnnotatedMethods() throws Exception {
- Class<?> c = Class.forName("fillers.ArrayFiller");
- Method[] m = c.getDeclaredMethods();
- for (Method method : m) {
- if (method.isAnnotationPresent(Filler.class)) {
- int a[] = (int[]) method.invoke(null);//static method
- Set<Class<? extends Sort>> subTypesOf = (new Reflections("sorters")).getSubTypesOf(Sort.class);
- for (Class<? extends Sort> c1 : subTypesOf) {
- Constructor<? extends Sort> emptyConstructor = c1.getConstructor();
- Sort objectToInvokeOn = emptyConstructor.newInstance();
- Method[] m1 = c1.getDeclaredMethods();
- for (Method method1 : m1) {
- if (a != null) {
- long start = System.nanoTime();
- method1.invoke(objectToInvokeOn, a);//тут ошибка
- long count = System.nanoTime() - start;
- System.out.println(count);
- }
- }
- }
- }
- }
- Map<Method, Map<Class, Long[]>> statistic = new HashMap<>();
- for (Entry<Method, Map<Class, Long[]>> statisticEntry : statistic.entrySet()) {
- Method statisticKey = statisticEntry.getKey();
- Map<Class, Long[]> substatistic = statisticEntry.getValue();
- for (Entry<Class, Long[]> substatisticEntry : substatistic.entrySet()) {
- Class substatisticKey = substatisticEntry.getKey();
- Long[] substatisticList = substatisticEntry.getValue();
- System.out.println(statisticKey + "t" + substatisticKey + "t" + substatisticList);
- }
- }
- }
- 162905767
- Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
- 2626612
- at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.base/java.lang.reflect.Method.invoke(Method.java:564)
- at analyzer.Analyzer.runAllAnnotatedMethods(Analyzer.java:29)
- at Main.main(Main.java:7)
- public class ArrayFiller {
- /**
- * This method create randomized array with a current length.
- */
- @Filler
- public static int[] randomized() {
- int a[]= new int[10000];
- for (Integer i = 0; i < a.length; i++) {
- a[i] = (int) Math.round(Math.random() * 100);
- }
- return a;
- }
- /**
- * This method create randomized array with a current length, than sort it.
- */
- @Filler
- public static int [] sortedArray() {
- int a[] = new int[10000];
- for (Integer i = 0; i < a.length; i++) {
- a[i] = (int) Math.round(Math.random() * 100);
- Arrays.sort(a);
- }
- return a;
- }
- public class ArraySort extends Sort{
- public ArraySort(){
- }
- public void arraySort(int[] a){
- Arrays.sort(a);
- }
- }
- public class Bubble extends Sort {
- public Bubble(){
- }
- public void bubble(int a[]) {
- for (int i = 0; i < a.length; i++) {
- for (int j = i - 1; j >= 0; j--) {
- if (a[j] > a[j + 1]) {
- swap(a, j, j + 1);
- public class BubbleSortDown extends Sort{
- public BubbleSortDown(){
- }
- public void bubbleSortDown(int[]a) {
- for (int i = a.length - 1; i >= 0; i--) {
- for (int j = i - 1; j >= 0; j--) {
- if (a[j] > a[i]) {
- swap(a, j, i);
Add Comment
Please, Sign In to add comment