package com.asb.demo.client.impl;

import com.asb.demo.client.StudentClient;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

/**
 * Created by arjun on 29/01/16.
 */
@BenchmarkMode(Mode.SingleShotTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread)
public class FastStudentClientBenchMark {

  private StudentClient studentClient;

  @Setup
  public void prepare() {
    studentClient = new FastStudentClient(1, true);
  }

  @Benchmark
  public void testParallel() {
    studentClient.setParallel(true);
    studentClient.getStudents().forEach(student -> System.out.println(student.getName()));
  }

  @Benchmark
  public void testSerial() {
    studentClient.setParallel(false);
    studentClient.getStudents().forEach(student -> System.out.println(student.getName()));
  }
}

@@ -70,16 +70,48 @@
 Client;%0A
+import com.asb.demo.eo.Student;%0A
 import o
@@ -141,16 +141,39 @@
 ons.*;%0A%0A
+import java.util.List;%0A
 import j
@@ -268,22 +268,11 @@
 ode.
-SingleShotTime
+All
 )%0A@O
@@ -298,12 +298,8 @@
 nit.
-NANO
 SECO
@@ -579,24 +579,49 @@
 l(true);%0A   
+ List%3CStudent%3E students =
  studentClie
@@ -636,35 +636,21 @@
 udents()
-.forEach(student -%3E
+;%0A   
  System.
@@ -661,35 +661,43 @@
 println(
-student.getNam
+%22Size: %22 + students.siz
 e())
-)
 ;%0A  %7D%0A%0A 
@@ -774,24 +774,49 @@
 (false);%0A   
+ List%3CStudent%3E students =
  studentClie
@@ -835,27 +835,13 @@
 ts()
-.forEach(student -%3E
+;%0A   
  Sys
@@ -860,27 +860,35 @@
 tln(
-student.getNam
+%22Size: %22 + students.siz
 e())
-)
 ;%0A  

Update the benchmark test