Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Java, 특정 로직에 대한 성능 확인(속도 체크)<br />김용환<br />
System.currentTimeMillis()<br />소스<br />long startTime = System.currentTimeMillis();Thread.sleep(1000);long estimatedTime ...
System.nanoTime() <br />소스<br />long time1 = System.nanoTime();Thread.sleep(1000);long time2 = System.nanoTime();long time...
Commons-lang의 StopWatch (2.3)<br />import org.apache.commons.lang.time.StopWatch;..StopWatchstopWatch = new StopWatch();st...
Spring core lib에 있는 util성 StopWatch (3.0)<br />소스<br />import org.springframework.util.StopWatch;...StopWatchstopWatch = n...
Spring core lib에 있는 util성 StopWatch (3.0)<br />결과<br />took 2000 mstook 5000 mstook 3001 msStopWatch 'Stop Watch': running...
남의 것 사용<br />그냥 인터넷에서 남들이 만든 StopWatch를 찾아서 copy&paste한다.http://www.devdaily.com/blog/post/java/stopwatch-class-that-can-b...
Commons-lang의 StopWatch와 Spring Util의 StopWatch비교<br />
Upcoming SlideShare
Loading in …5
×

속도체크

4,259 views

Published on

Published in: Business, Technology
  • Follow the link, new dating source: ♥♥♥ http://bit.ly/39pMlLF ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Sex in your area is here: ❤❤❤ http://bit.ly/39pMlLF ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

속도체크

  1. 1. Java, 특정 로직에 대한 성능 확인(속도 체크)<br />김용환<br />
  2. 2. System.currentTimeMillis()<br />소스<br />long startTime = System.currentTimeMillis();Thread.sleep(1000);long estimatedTime = System.currentTimeMillis() - startTime;System.out.println("took " + estimatedTime + " ms");<br />결과<br />took 1000 ms<br />
  3. 3. System.nanoTime() <br />소스<br />long time1 = System.nanoTime();Thread.sleep(1000);long time2 = System.nanoTime();long timeSpent = time2 - time1;System.out.println("took " + timeSpent + " ns");<br />결과<br />took 1000232514 ns<br />
  4. 4. Commons-lang의 StopWatch (2.3)<br />import org.apache.commons.lang.time.StopWatch;..StopWatchstopWatch = new StopWatch();stopWatch.reset();stopWatch.start();Thread.sleep(2000);stopWatch.stop();System.out.println(stopWatch.toString());  stopWatch.reset();stopWatch.start();Thread.sleep(5000);stopWatch.stop();System.out.println(stopWatch.toString());  stopWatch.reset();stopWatch.start();Thread.sleep(3000);stopWatch.stop();System.out.println(stopWatch.toString());<br />소스<br />0:00:02.0000:00:05.0000:00:03.000<br />결과<br />
  5. 5. Spring core lib에 있는 util성 StopWatch (3.0)<br />소스<br />import org.springframework.util.StopWatch;...StopWatchstopWatch = new StopWatch("Stop Watch");stopWatch.start("initializing");Thread.sleep(2000);stopWatch.stop();System.out.println("took " + stopWatch.getLastTaskTimeMillis() + " ms");<br />stopWatch.start("processing");Thread.sleep(5000);stopWatch.stop();System.out.println("took " + stopWatch.getLastTaskTimeMillis() + " ms");  stopWatch.start("finalizing");Thread.sleep(3000);stopWatch.stop();System.out.println("took " + stopWatch.getLastTaskTimeMillis() + " ms");  System.out.println(stopWatch.toString());System.out.println();System.out.println(stopWatch.prettyPrint());<br />
  6. 6. Spring core lib에 있는 util성 StopWatch (3.0)<br />결과<br />took 2000 mstook 5000 mstook 3001 msStopWatch 'Stop Watch': running time (millis) = 10001; [initializing] took 2000 = 20%; [processing] took 5000 = 50%; [finalizing] took 3001 = 30%<br />StopWatch 'Stop Watch': running time (millis) = 10001-----------------------------------------ms     %     Task name-----------------------------------------02000  020%  initializing05000  050%  processing03001  030%  finalizing<br />
  7. 7. 남의 것 사용<br />그냥 인터넷에서 남들이 만든 StopWatch를 찾아서 copy&paste한다.http://www.devdaily.com/blog/post/java/stopwatch-class-that-can-be-used-for-timings-benchmarks<br />
  8. 8. Commons-lang의 StopWatch와 Spring Util의 StopWatch비교<br />

×