test/micro/org/openjdk/bench/java/net/SocketChannelCompare.java
branchunixdomainchannels
changeset 59003 aaba7cc40951
parent 58935 f31f0c8bff89
equal deleted inserted replaced
58988:b88e23c84b23 59003:aaba7cc40951
    34 import java.nio.file.*;
    34 import java.nio.file.*;
    35 import java.util.concurrent.TimeUnit;
    35 import java.util.concurrent.TimeUnit;
    36 import java.util.concurrent.atomic.AtomicInteger;
    36 import java.util.concurrent.atomic.AtomicInteger;
    37 
    37 
    38 import org.openjdk.jmh.annotations.*;
    38 import org.openjdk.jmh.annotations.*;
       
    39 import org.openjdk.jmh.runner.Runner;
       
    40 import org.openjdk.jmh.runner.RunnerException;
       
    41 import org.openjdk.jmh.runner.options.Options;
       
    42 import org.openjdk.jmh.runner.options.OptionsBuilder;
    39 
    43 
    40 /**
    44 /**
    41  * Tests sending a 128 byte message on a second, to a thread which
    45  * Tests sending a 128 byte message on a second, to a thread which
    42  * echo's it back and received by the original thread.
    46  * echo's it back and received by the original thread.
    43  * Benchmark is performed for "inet" channels over TCP/IP
    47  * Benchmark is performed for "inet" channels over TCP/IP
   157                     sc.write(bb);
   161                     sc.write(bb);
   158                 }
   162                 }
   159             } catch (ClosedChannelException ex) {
   163             } catch (ClosedChannelException ex) {
   160                 // shutdown time
   164                 // shutdown time
   161             } catch (IOException ioex) {
   165             } catch (IOException ioex) {
   162 		ioex.printStackTrace();
   166                 ioex.printStackTrace();
   163             }
   167             }
   164         }
   168         }
   165     }
   169     }
       
   170 
       
   171     public static void main(String[] args) throws RunnerException {
       
   172         Options opt = new OptionsBuilder()
       
   173                 .include(org.openjdk.bench.java.net.SocketChannelCompare.class.getSimpleName())
       
   174                 .forks(3)
       
   175                 .build();
       
   176 
       
   177         new Runner(opt).run();
       
   178 
       
   179         opt = new OptionsBuilder()
       
   180                 .include(org.openjdk.bench.java.net.SocketChannelCompare.class.getSimpleName())
       
   181                 .jvmArgsPrepend("-Djdk.net.useFastTcpLoopback=true")
       
   182                 .forks(3)
       
   183                 .build();
       
   184 
       
   185         new Runner(opt).run();
       
   186     }
   166 }
   187 }