daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Jan 18th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Analyzer {
  2. public static void runAllAnnotatedMethods() throws Exception {
  3.     Class<?> c = Class.forName("fillers.ArrayFiller");
  4.     Method[] m = c.getDeclaredMethods();
  5.     for (Method method : m) {
  6.         if (method.isAnnotationPresent(Filler.class)) {
  7.             int a[] = (int[]) method.invoke(null);//static method
  8.             Set<Class<? extends Sort>> subTypesOf = (new Reflections("sorters")).getSubTypesOf(Sort.class);
  9.             for (Class<? extends Sort> c1 : subTypesOf) {
  10.                 Constructor<? extends Sort> emptyConstructor = c1.getConstructor();
  11.                 Sort objectToInvokeOn = emptyConstructor.newInstance();
  12.                 Method[] m1 = c1.getDeclaredMethods();
  13.                 for (Method method1 : m1) {
  14.                     if (a != null) {
  15.                         long start = System.nanoTime();
  16.                         method1.invoke(objectToInvokeOn, a);//тут ошибка
  17.                         long count = System.nanoTime() - start;
  18.                         System.out.println(count);
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.     }
  24.  
  25.     Map<Method, Map<Class, Long[]>> statistic = new HashMap<>();
  26.     for (Entry<Method, Map<Class, Long[]>> statisticEntry : statistic.entrySet()) {
  27.         Method statisticKey = statisticEntry.getKey();
  28.         Map<Class, Long[]> substatistic = statisticEntry.getValue();
  29.         for (Entry<Class, Long[]> substatisticEntry : substatistic.entrySet()) {
  30.             Class substatisticKey = substatisticEntry.getKey();
  31.             Long[] substatisticList = substatisticEntry.getValue();
  32.             System.out.println(statisticKey + "t" + substatisticKey + "t" + substatisticList);
  33.         }
  34.     }
  35. }
  36.    
  37. 162905767
  38. Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
  39. 2626612
  40.     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  41.     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  42.     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  43.     at java.base/java.lang.reflect.Method.invoke(Method.java:564)
  44.     at analyzer.Analyzer.runAllAnnotatedMethods(Analyzer.java:29)
  45.     at Main.main(Main.java:7)
  46.    
  47. public class ArrayFiller {
  48. /**
  49.  * This method create randomized array with a current length.
  50.  */
  51. @Filler
  52. public static int[] randomized() {
  53.     int a[]= new int[10000];
  54.     for (Integer i = 0; i < a.length; i++) {
  55.         a[i] = (int) Math.round(Math.random() * 100);
  56.     }
  57.     return a;
  58. }
  59.  
  60. /**
  61.  * This method create randomized array with a current length, than sort it.
  62.  */
  63. @Filler
  64. public static int [] sortedArray() {
  65.     int a[] = new int[10000];
  66.     for (Integer i = 0; i < a.length; i++) {
  67.         a[i] = (int) Math.round(Math.random() * 100);
  68.         Arrays.sort(a);
  69.     }
  70.     return a;
  71. }
  72.    
  73. public class ArraySort extends Sort{
  74.     public ArraySort(){
  75.     }
  76.     public void arraySort(int[] a){
  77.         Arrays.sort(a);
  78.     }
  79.     }
  80.  
  81. public class Bubble extends Sort {
  82.     public Bubble(){
  83.  
  84.     }
  85.  
  86.   public  void bubble(int a[]) {
  87.  
  88.           for (int i = 0; i < a.length; i++) {
  89.               for (int j = i - 1; j >= 0; j--) {
  90.                   if (a[j] > a[j + 1]) {
  91.                       swap(a, j, j + 1);
  92.  
  93. public class BubbleSortDown extends Sort{
  94.     public BubbleSortDown(){
  95.  
  96.     }
  97.     public void bubbleSortDown(int[]a) {
  98.             for (int i = a.length - 1; i >= 0; i--) {
  99.                 for (int j = i - 1; j >= 0; j--) {
  100.                     if (a[j] > a[i]) {
  101.                         swap(a, j, i);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top