ݺߣ

ݺߣShare a Scribd company logo
Java, 특정 로직에 대한 성능 확인(속도 체크)김용환
System.currentTimeMillis()소스long startTime = System.currentTimeMillis();Thread.sleep(1000);long estimatedTime = System.currentTimeMillis() - startTime;System.out.println("took " + estimatedTime + " ms");결과took 1000 ms
System.nanoTime() 소스long time1 = System.nanoTime();Thread.sleep(1000);long time2 = System.nanoTime();long timeSpent = time2 - time1;System.out.println("took " + timeSpent + " ns");결과took 1000232514 ns
Commons-lang의 StopWatch (2.3)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());소스0:00:02.0000:00:05.0000:00:03.000결과
Spring core lib에 있는 util성 StopWatch (3.0)소스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");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());
Spring core lib에 있는 util성 StopWatch (3.0)결과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%StopWatch 'Stop Watch': running time (millis) = 10001-----------------------------------------ms % Task name-----------------------------------------02000 020% initializing05000 050% processing03001 030% finalizing
남의 것 사용그냥 인터넷에서 남들이 만든 StopWatch를 찾아서 copy&paste한다.http://www.devdaily.com/blog/post/java/stopwatch-class-that-can-be-used-for-timings-benchmarks
Commons-lang의 StopWatch와 Spring Util의 StopWatch비교
Ad

Recommended

[Curso Java Basico] Aula 69: Criando varias Threads + metodos isAlive e join
[Curso Java Basico] Aula 69: Criando varias Threads + metodos isAlive e join
Loiane Groner
streamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with storm
Daniel Blanchard
Real-time streams and logs with Storm and Kafka
Real-time streams and logs with Storm and Kafka
Andrew Montalenti
[Curso Java Basico] Aula 70: Threads: Definindo prioridades
[Curso Java Basico] Aula 70: Threads: Definindo prioridades
Loiane Groner
제 8회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 8회 엑셈 수요 세미나 자료 연구컨텐츠팀
EXEM
Apc optimization
Apc optimization
Alex Raskin
Retrofit caching V1.9.0 - Android OkClient
Retrofit caching V1.9.0 - Android OkClient
Mathan Raj
tp smarts_onboarding
tp smarts_onboarding
♛Kumar Aneesh♛
Openstack Neutron LBAAS
Openstack Neutron LBAAS
Narasimha sreeram
Multi threading
Multi threading
PavanAnudeepMotiki
Sge
Sge
Chris Roeder
Dev ops on startup environment
Dev ops on startup environment
Evaldo Felipe
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
Ontico
Python multithreaded programming
Python multithreaded programming
Learnbay Datascience
Odoo Performance Limits
Odoo Performance Limits
Odoo
Scheduling torque-maui-tutorial
Scheduling torque-maui-tutorial
Santosh Kumar
Tarantool как платформа для микросервисов / Антон Резников, Владимир Перепели...
Tarantool как платформа для микросервисов / Антон Резников, Владимир Перепели...
Ontico
Am I reading GC logs Correctly?
Am I reading GC logs Correctly?
Tier1 App
Advanced patterns in asynchronous programming
Advanced patterns in asynchronous programming
Michael Arenzon
Cloud Services - Gluecon 2010
Cloud Services - Gluecon 2010
Oren Teich
Pick diamonds from garbage
Pick diamonds from garbage
Tier1 App
Training ݺߣs: Basics 105: Backup, Recovery and Provisioning Within Tungste...
Training ݺߣs: Basics 105: Backup, Recovery and Provisioning Within Tungste...
Continuent
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Ontico
JS Lab2017_Андрей Кучеренко _Разработка мультипакетных приложения: причины, с...
JS Lab2017_Андрей Кучеренко _Разработка мультипакетных приложения: причины, с...
GeeksLab Odessa
Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)
Alexey Fyodorov
Spork || How To Streamline Your TDD Process
Spork || How To Streamline Your TDD Process
Arik Fraimovich
Much Ado About Blocking: Wait/Wakke in the Linux Kernel
Much Ado About Blocking: Wait/Wakke in the Linux Kernel
Davidlohr Bueso
Backtracking Algorithmic Complexity Attacks Against a NIDS
Backtracking Algorithmic Complexity Attacks Against a NIDS
amiable_indian
Hancom MDS Conference - KAKAO DEVOPS Practice (카카오 스토리의 Devops 사례)
Hancom MDS Conference - KAKAO DEVOPS Practice (카카오 스토리의 Devops 사례)
knight1128

More Related Content

What's hot (20)

Openstack Neutron LBAAS
Openstack Neutron LBAAS
Narasimha sreeram
Multi threading
Multi threading
PavanAnudeepMotiki
Sge
Sge
Chris Roeder
Dev ops on startup environment
Dev ops on startup environment
Evaldo Felipe
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
Ontico
Python multithreaded programming
Python multithreaded programming
Learnbay Datascience
Odoo Performance Limits
Odoo Performance Limits
Odoo
Scheduling torque-maui-tutorial
Scheduling torque-maui-tutorial
Santosh Kumar
Tarantool как платформа для микросервисов / Антон Резников, Владимир Перепели...
Tarantool как платформа для микросервисов / Антон Резников, Владимир Перепели...
Ontico
Am I reading GC logs Correctly?
Am I reading GC logs Correctly?
Tier1 App
Advanced patterns in asynchronous programming
Advanced patterns in asynchronous programming
Michael Arenzon
Cloud Services - Gluecon 2010
Cloud Services - Gluecon 2010
Oren Teich
Pick diamonds from garbage
Pick diamonds from garbage
Tier1 App
Training ݺߣs: Basics 105: Backup, Recovery and Provisioning Within Tungste...
Training ݺߣs: Basics 105: Backup, Recovery and Provisioning Within Tungste...
Continuent
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Ontico
JS Lab2017_Андрей Кучеренко _Разработка мультипакетных приложения: причины, с...
JS Lab2017_Андрей Кучеренко _Разработка мультипакетных приложения: причины, с...
GeeksLab Odessa
Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)
Alexey Fyodorov
Spork || How To Streamline Your TDD Process
Spork || How To Streamline Your TDD Process
Arik Fraimovich
Much Ado About Blocking: Wait/Wakke in the Linux Kernel
Much Ado About Blocking: Wait/Wakke in the Linux Kernel
Davidlohr Bueso
Backtracking Algorithmic Complexity Attacks Against a NIDS
Backtracking Algorithmic Complexity Attacks Against a NIDS
amiable_indian
Dev ops on startup environment
Dev ops on startup environment
Evaldo Felipe
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
Ontico
Odoo Performance Limits
Odoo Performance Limits
Odoo
Scheduling torque-maui-tutorial
Scheduling torque-maui-tutorial
Santosh Kumar
Tarantool как платформа для микросервисов / Антон Резников, Владимир Перепели...
Tarantool как платформа для микросервисов / Антон Резников, Владимир Перепели...
Ontico
Am I reading GC logs Correctly?
Am I reading GC logs Correctly?
Tier1 App
Advanced patterns in asynchronous programming
Advanced patterns in asynchronous programming
Michael Arenzon
Cloud Services - Gluecon 2010
Cloud Services - Gluecon 2010
Oren Teich
Pick diamonds from garbage
Pick diamonds from garbage
Tier1 App
Training ݺߣs: Basics 105: Backup, Recovery and Provisioning Within Tungste...
Training ݺߣs: Basics 105: Backup, Recovery and Provisioning Within Tungste...
Continuent
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Ontico
JS Lab2017_Андрей Кучеренко _Разработка мультипакетных приложения: причины, с...
JS Lab2017_Андрей Кучеренко _Разработка мультипакетных приложения: причины, с...
GeeksLab Odessa
Spork || How To Streamline Your TDD Process
Spork || How To Streamline Your TDD Process
Arik Fraimovich
Much Ado About Blocking: Wait/Wakke in the Linux Kernel
Much Ado About Blocking: Wait/Wakke in the Linux Kernel
Davidlohr Bueso
Backtracking Algorithmic Complexity Attacks Against a NIDS
Backtracking Algorithmic Complexity Attacks Against a NIDS
amiable_indian

More from knight1128 (19)

Hancom MDS Conference - KAKAO DEVOPS Practice (카카오 스토리의 Devops 사례)
Hancom MDS Conference - KAKAO DEVOPS Practice (카카오 스토리의 Devops 사례)
knight1128
Apache Thrift
Apache Thrift
knight1128
Spring MVC 3 Restful
Spring MVC 3 Restful
knight1128
Jersey framework
Jersey framework
knight1128
Google Protocol buffer
Google Protocol buffer
knight1128
Jdk(java) 7 - 5. invoke-dynamic
Jdk(java) 7 - 5. invoke-dynamic
knight1128
Jdk(java) 7 - 6 기타기능
Jdk(java) 7 - 6 기타기능
knight1128
Jdk 7 4-forkjoin
Jdk 7 4-forkjoin
knight1128
공유 Jdk 7-2-project coin
공유 Jdk 7-2-project coin
knight1128
공유 Jdk 7-1-short introduction
공유 Jdk 7-1-short introduction
knight1128
아마존 Aws 서비스_연구
아마존 Aws 서비스_연구
knight1128
오픈소스를 활용한 Batch_처리_플랫폼_공유
오픈소스를 활용한 Batch_처리_플랫폼_공유
knight1128
Ssl 하드웨어 가속기를 이용한 성능 향상
Ssl 하드웨어 가속기를 이용한 성능 향상
knight1128
Hancom MDS Conference - KAKAO DEVOPS Practice (카카오 스토리의 Devops 사례)
Hancom MDS Conference - KAKAO DEVOPS Practice (카카오 스토리의 Devops 사례)
knight1128
Spring MVC 3 Restful
Spring MVC 3 Restful
knight1128
Google Protocol buffer
Google Protocol buffer
knight1128
Jdk(java) 7 - 5. invoke-dynamic
Jdk(java) 7 - 5. invoke-dynamic
knight1128
Jdk(java) 7 - 6 기타기능
Jdk(java) 7 - 6 기타기능
knight1128
공유 Jdk 7-2-project coin
공유 Jdk 7-2-project coin
knight1128
공유 Jdk 7-1-short introduction
공유 Jdk 7-1-short introduction
knight1128
아마존 Aws 서비스_연구
아마존 Aws 서비스_연구
knight1128
오픈소스를 활용한 Batch_처리_플랫폼_공유
오픈소스를 활용한 Batch_처리_플랫폼_공유
knight1128
Ssl 하드웨어 가속기를 이용한 성능 향상
Ssl 하드웨어 가속기를 이용한 성능 향상
knight1128
Ad

Recently uploaded (20)

StatementOfResult.pdf........................
StatementOfResult.pdf........................
AnnasofiaUrsini
ISO 45001 Certification in Singapore Company
ISO 45001 Certification in Singapore Company
achharsharma105
What is Interior designing(introduction).pdf
What is Interior designing(introduction).pdf
bhatiagitali
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip
Podcast Show Notes - Rapid International Expansion for Scale-up Stage Tech Bu...
Podcast Show Notes - Rapid International Expansion for Scale-up Stage Tech Bu...
Dave Litwiller
“Built with our sleeves rolled up”Action
“Built with our sleeves rolled up”Action
Action EDI
ASEAN ISO Tank Container Market Size, Growth and Forecast | 2034
ASEAN ISO Tank Container Market Size, Growth and Forecast | 2034
GeorgeButtler
Redefining Business Experiences: The Role of a Corporate Event Management Com...
Redefining Business Experiences: The Role of a Corporate Event Management Com...
Be Executive Events
Stuart Frost - The Chief Executive Officer Of Geminos
Stuart Frost - The Chief Executive Officer Of Geminos
Stuart Frost
Extending Infrastructure Life with Protective Coatings
Extending Infrastructure Life with Protective Coatings
rahil wit
Marc Belluomini - An Impressive Career In Boom Operation
Marc Belluomini - An Impressive Career In Boom Operation
Marc Belluomini
The Executive’s Guide to Stress-Free Airport Transfers in London
The Executive’s Guide to Stress-Free Airport Transfers in London
Jannah Express
chapter 9 leadership qualityies university of windsor
chapter 9 leadership qualityies university of windsor
zamananalyst29
Oleksandr Osypenko: Комунікації у проєкті (UA)
Oleksandr Osypenko: Комунікації у проєкті (UA)
Lviv Startup Club
zlib.pub_fundamental-analysis-for-investors-4th-edition.pdf
zlib.pub_fundamental-analysis-for-investors-4th-edition.pdf
ssuserc74044
Zero-emission zones in the Netherlands 2025
Zero-emission zones in the Netherlands 2025
Walther Ploos van Amstel
Oleksandr Osypenko: Assessing Organizational Readiness (UA)
Oleksandr Osypenko: Assessing Organizational Readiness (UA)
Lviv Startup Club
Thesis Exam I Putu SuryaSFSDFSDFS Pradnya Adiwinata.pdf.pptx
Thesis Exam I Putu SuryaSFSDFSDFS Pradnya Adiwinata.pdf.pptx
SURYAADIWINATA3
Ian McAllister - Respected Photographer And Writer
Ian McAllister - Respected Photographer And Writer
Ian McAllister
Integrating Scrum into a Time-Boxed Mission
Integrating Scrum into a Time-Boxed Mission
RaulAmavisca
StatementOfResult.pdf........................
StatementOfResult.pdf........................
AnnasofiaUrsini
ISO 45001 Certification in Singapore Company
ISO 45001 Certification in Singapore Company
achharsharma105
What is Interior designing(introduction).pdf
What is Interior designing(introduction).pdf
bhatiagitali
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip
Podcast Show Notes - Rapid International Expansion for Scale-up Stage Tech Bu...
Podcast Show Notes - Rapid International Expansion for Scale-up Stage Tech Bu...
Dave Litwiller
“Built with our sleeves rolled up”Action
“Built with our sleeves rolled up”Action
Action EDI
ASEAN ISO Tank Container Market Size, Growth and Forecast | 2034
ASEAN ISO Tank Container Market Size, Growth and Forecast | 2034
GeorgeButtler
Redefining Business Experiences: The Role of a Corporate Event Management Com...
Redefining Business Experiences: The Role of a Corporate Event Management Com...
Be Executive Events
Stuart Frost - The Chief Executive Officer Of Geminos
Stuart Frost - The Chief Executive Officer Of Geminos
Stuart Frost
Extending Infrastructure Life with Protective Coatings
Extending Infrastructure Life with Protective Coatings
rahil wit
Marc Belluomini - An Impressive Career In Boom Operation
Marc Belluomini - An Impressive Career In Boom Operation
Marc Belluomini
The Executive’s Guide to Stress-Free Airport Transfers in London
The Executive’s Guide to Stress-Free Airport Transfers in London
Jannah Express
chapter 9 leadership qualityies university of windsor
chapter 9 leadership qualityies university of windsor
zamananalyst29
Oleksandr Osypenko: Комунікації у проєкті (UA)
Oleksandr Osypenko: Комунікації у проєкті (UA)
Lviv Startup Club
zlib.pub_fundamental-analysis-for-investors-4th-edition.pdf
zlib.pub_fundamental-analysis-for-investors-4th-edition.pdf
ssuserc74044
Oleksandr Osypenko: Assessing Organizational Readiness (UA)
Oleksandr Osypenko: Assessing Organizational Readiness (UA)
Lviv Startup Club
Thesis Exam I Putu SuryaSFSDFSDFS Pradnya Adiwinata.pdf.pptx
Thesis Exam I Putu SuryaSFSDFSDFS Pradnya Adiwinata.pdf.pptx
SURYAADIWINATA3
Ian McAllister - Respected Photographer And Writer
Ian McAllister - Respected Photographer And Writer
Ian McAllister
Integrating Scrum into a Time-Boxed Mission
Integrating Scrum into a Time-Boxed Mission
RaulAmavisca
Ad

속도체크

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