示例#1
0
  /**
   * Łączenie list w jeden łańcuch znakowy
   *
   * @param p lista osób do połączenia
   */
  public static void joinStrings(List<Person> p) {
    long l1 = System.nanoTime();
    String s1 = "";
    for (Person p1 : p) {
      s1 += p1.toString() + "\n";
    }
    long l2 = System.nanoTime();

    // System.out.println(s1);
    // System.out.println("================================================");

    long l3 = System.nanoTime();
    String s2 = joinFrom(p, "\n").toString();
    long l4 = System.nanoTime();
    // System.out.println(s2);

    System.out.println("lambda/classic : " + (l4 - l3) / (l2 - l1));
  }
示例#2
0
  /**
   * Ekstraktownie zadanej własności do listy
   *
   * @param p
   */
  public static void extraktowanie(List<Person> p) {
    long l1 = System.nanoTime();
    List<String> names1 = new ArrayList<String>();
    for (Person pers : p) {
      names1.add(pers.getName());
    }
    long l2 = System.nanoTime();

    long l3 = System.nanoTime();
    List<String> names2 = extract(p, on(Person.class).getName());
    long l4 = System.nanoTime();

    //		StartLambda.print.each(names1);
    //		System.out.println("===============================================");
    //		StartLambda.print.each(names2);
    //		System.out.println("===============================================");

    System.out.println("lambda/classic : " + (((double) (l4 - l3)) / ((double) (l2 - l1))));
  }