@@ -0,0 +1,2989 @@
+package com.gzs.learn.datetime;%0A%0Aimport java.text.ParseException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.concurrent.CountDownLatch;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0A%0Aimport org.junit.Test;%0A%0Aimport com.google.common.base.Stopwatch;%0A%0Aimport lombok.extern.slf4j.Slf4j;%0A%0A@Slf4j%0Apublic class DateFormatPerfTest %7B%0A    private String pattern = %22yyyy-MM-dd HH:mm:ss%22;%0A    private int threadNum = 10;%0A    private int loopTimes = 1000000;%0A    private final ThreadLocal%3CSimpleDateFormat%3E sdfLocal =%0A            ThreadLocal.withInitial(() -%3E new SimpleDateFormat(pattern));%0A    private ExecutorService executorService = Executors.newFixedThreadPool(10);%0A%0A    @Test%0A    public void testSdfLocal() throws InterruptedException %7B%0A        Stopwatch stopwatch = Stopwatch.createStarted();%0A        final CountDownLatch latch = new CountDownLatch(threadNum);%0A        for (int i = 0; i %3C threadNum; i++) %7B%0A            executorService.submit(() -%3E %7B%0A                for (int j = 0; j %3C loopTimes; j++) %7B%0A                    SimpleDateFormat sdf = sdfLocal.get();%0A                    try %7B%0A                        sdf.parse(%222010-10-01 00:00:10%22);%0A                    %7D catch (ParseException e) %7B%0A                        e.printStackTrace();%0A                    %7D%0A                %7D%0A                latch.countDown();%0A            %7D);%0A%0A        %7D%0A        latch.await();%0A        stopwatch.stop();%0A        log.info(%22sdf local cost:%22 + stopwatch.toString());%0A    %7D%0A%0A%0A    @Test%0A    public void testSdf() throws InterruptedException %7B%0A        Stopwatch stopwatch = Stopwatch.createStarted();%0A        final CountDownLatch latch = new CountDownLatch(threadNum);%0A        for (int i = 0; i %3C threadNum; i++) %7B%0A            executorService.submit(() -%3E %7B%0A                for (int j = 0; j %3C loopTimes; j++) %7B%0A                    SimpleDateFormat sdf = new SimpleDateFormat(pattern);%0A                    try %7B%0A                        sdf.parse(%222010-10-01 00:00:10%22);%0A                    %7D catch (ParseException e) %7B%0A                        e.printStackTrace();%0A                    %7D%0A                %7D%0A                latch.countDown();%0A            %7D);%0A%0A        %7D%0A        latch.await();%0A        stopwatch.stop();%0A        log.info(%22sdf cost:%22 + stopwatch.toString());%0A    %7D%0A%0A    @Test%0A    public void testPojo() throws InterruptedException %7B%0A        Stopwatch stopwatch = Stopwatch.createStarted();%0A        final CountDownLatch latch = new CountDownLatch(threadNum);%0A        for (int i = 0; i %3C threadNum; i++) %7B%0A            executorService.submit(() -%3E %7B%0A                for (int j = 0; j %3C loopTimes; j++) %7B%0A                    new Pojo();%0A                    // new Object();%0A                %7D%0A                latch.countDown();%0A            %7D);%0A%0A        %7D%0A        latch.await();%0A        stopwatch.stop();%0A        log.info(%22pojo cost:%22 + stopwatch.toString());%0A    %7D%0A%0A%7D%0A%0A%0Aclass Pojo %7B%0A    int id = 0;%0A    String name = %22123%22;%0A    Object object = new Object();%0A%7D%0A

add simpledateformat perf test