unit testing performance in java projects are we there yet
play

Unit Testing Performance in Java Projects: Are We There Yet? Petr - PowerPoint PPT Presentation

Unit Testing Performance in Java Projects: Are We There Yet? Petr Stefan, Vojtch Hork , Lubomr Bulej and Petr Tma Charles University Unit Testing Performance in Java Projects: Are We There Yet? Unit Testing Performance in Java


  1. Unit Testing Performance in Java Projects: Are We There Yet? Petr Stefan, Vojtěch Horký , Lubomír Bulej and Petr Tůma Charles University

  2. Unit Testing Performance in Java Projects: Are We There Yet?

  3. Unit Testing Performance in Java Projects: Are We There Yet? Short, isolated performance tests of individual components. Suitable to be run during nightly builds.

  4. Unit Testing Performance in Java Projects: Are We There Yet? Where else :-)

  5. Unit Testing Performance in Java Projects: Are We There Yet? How many projects have such tests? ...

  6. “Are We There Yet?” Expanded – How many projects have performance unit tests? – Which framework is used for these tests? – What kind of projects care about performance? – How often are performance unit tests changed (maintained)? – Are the tests short enough for “after every commit” execution? – What (de)motivates developers towards performance tests?

  7. Setup

  8. Getting the Data Semi-automated exploration of open source projects. Survey for developers that actually added/updated the performance tests.

  9. Getting the Projects GitHub as one of the prominent hosting platforms. Almost 2.5 million of Java projects.

  10. Getting the Projects GitHub as one of the prominent hosting platforms. Almost 2.5 million of Java projects. We limit ourselves to projects with a fork to filter out abandoned repositories, toy examples and school assignments.

  11. Getting the Projects GitHub as one of the prominent hosting platforms. Almost 2.5 million of Java projects. We limit ourselves to projects with a fork to filter out abandoned repositories, toy examples and school assignments. That totals to almost 100 thousand projects and over 3TB of data.

  12. Developer’s Survey Targeted committers that modified the performance tests.

  13. Developer’s Survey Targeted committers that modified the performance tests. 483 invitations, 111 responses. Questions steered by results of source code analysis.

  14. Results

  15. Which Frameworks Do the Projects Use? Methodology: parse the Java code, look for typical annotations or base classes . . .

  16. Which Frameworks Do the Projects Use? Methodology: parse the Java code, look for typical annotations or base classes . . . Example: this marks JMH (or Caliper) test (we use full-fledged parser to resolve ambiguities through imports): @Benchmark public void x() { ... }

  17. Which Frameworks Do the Projects Use? Methodology: parse the Java code, look for typical annotations or base classes . . . Example: this marks JMH (or Caliper) test (we use full-fledged parser to resolve ambiguities through imports): @Benchmark public void x() { ... } We look for two functional testing frameworks and five performance testing frameworks.

  18. Testing Frameworks Framework Repositories Relative usage JUnit 4 30871 31 . 177 % TestNG 2053 2 . 073 % Caliper 12 0 . 012 % ContiPerf 17 0 . 017 % Japex 52 0 . 053 % JMH 278 0 . 281 % JUnitPerf 11 0 . 011 %

  19. Testing Frameworks Framework Repositories Relative usage JUnit 4 30871 31 . 177 % TestNG 2053 2 . 073 % Caliper 12 0 . 012 % ContiPerf 17 0 . 017 % Japex 52 0 . 053 % JMH 278 0 . 281 % JUnitPerf 11 0 . 011 % From the survey: JMH is the most popular because developers trusts the results, like the documentation and active maintenance.

  20. Project Count Over Time JUnit JMH 250 25000 Project count Project count 150 10000 50 0 0 2010 2013 2016 2010 2013 2016 Year Year

  21. When Tests Are Introduced JUnit JMH 100 100 Relative test count [%] 75 75 50 50 25 25 0 0 Project lifetime ( ← Initial commit; HEAD → )

  22. When Tests Are Introduced JUnit JMH 100 100 Relative test count [%] 75 75 50 50 25 25 0 0 Project lifetime ( ← Initial commit; HEAD → ) From the survey: less than one third of developers maintains performance code regularly. Two thirds updates the tests only when addressing performance issues.

  23. Home-baked Performance Testing Not everybody is using testing frameworks . . .

  24. Home-baked Performance Testing Not everybody is using testing frameworks . . . 1. Took 1 000 projects randomly.

  25. Home-baked Performance Testing Not everybody is using testing frameworks . . . 1. Took 1 000 projects randomly. 2. Look for code that queries system clock.

  26. Home-baked Performance Testing Not everybody is using testing frameworks . . . 1. Took 1 000 projects randomly. 2. Look for code that queries system clock. 3. Determine whether it is used for benchmarking.

  27. Home-baked Performance Testing Not everybody is using testing frameworks . . . 1. Took 1 000 projects randomly. 2. Look for code that queries system clock. 3. Determine whether it is used for benchmarking. About 3% of the projects use it for benchmarking (we err on the optimistic side).

  28. Exploring Projects with JMH Tests JMH-based projects only. – Only framework with at least permille representation. – Standardized execution. – Apart from Caliper the only framework maintained till today.

  29. JMH Projects Classification Category Count Database (ORM, SQL . . . ) 33 Tutorials and examples 30 Networking and distributed systems 29 Algorithms 27 Data structures 22 Object serialization, parsers (XML, JSON, . . . ) 22 Web frameworks or plugins 18

  30. Size of Projects Using JMH 150 Project count 100 50 0 0 50 100 150 200 250 300 Project size [thousands of lines of code] (9 largest projects omitted)

  31. Can We Run the Tests After Each Commit? 20 Project count 15 10 5 0 0 50 100 150 200 Benchmark duration [min] From the survey: less than one half of developers run the tests regularly.

  32. One Hour Budget: Accuracy of Performance Data 60 50 Project count 40 30 20 10 0 0 2000 4000 6000 8000 10000 Relative confidence interval size [%]

  33. One Hour Budget: Accuracy of Performance Data 12 10 Project count 8 6 4 2 0 0 20 40 60 80 100 Relative confidence interval size [%]

  34. Greater Adoption of Performance Tests In the survey, we have learned that – not enough time/money to maintain the tests (27%)

  35. Greater Adoption of Performance Tests In the survey, we have learned that – not enough time/money to maintain the tests (27%) – regular performance testing is rare (42%)

  36. Greater Adoption of Performance Tests In the survey, we have learned that – not enough time/money to maintain the tests (27%) – regular performance testing is rare (42%) – tool integration with build infrastructure is too complex (50%)

  37. Greater Adoption of Performance Tests In the survey, we have learned that – not enough time/money to maintain the tests (27%) – regular performance testing is rare (42%) – tool integration with build infrastructure is too complex (50%) – developers miss (simple) automated evaluation (60%)

  38. Greater Adoption of Performance Tests In the survey, we have learned that – not enough time/money to maintain the tests (27%) – regular performance testing is rare (42%) – tool integration with build infrastructure is too complex (50%) – developers miss (simple) automated evaluation (60%)

  39. Towards Simple Evaluation From the survey: for one third of developers JMH is complex.

  40. Towards Simple Evaluation From the survey: for one third of developers JMH is complex. Our extension to JMH – To JMH itself: dump raw data (more of them). – New Maven plugin: compares two runs of a JMH benchmark to simplify regression benchmarking.

  41. Unit Testing Performance in Java Projects: Are We There Yet?

  42. Unit Testing Performance in Java Projects: Are We There Yet? Not really ;-)

  43. Unit Testing Performance in Java Projects: Are We There Yet? Performance tests are in less than 3 % of Java projects (functional tests are present in about one third).

  44. Unit Testing Performance in Java Projects: Are We There Yet? Performance tests are in less than 3 % of Java projects (functional tests are present in about one third). The existing tests are not suitable for build-time testing (complex setup, limited budget, little pressure to do so).

  45. Unit Testing Performance in Java Projects: Are We There Yet? Performance tests are in less than 3 % of Java projects (functional tests are present in about one third). The existing tests are not suitable for build-time testing (complex setup, limited budget, little pressure to do so). Complexity of the benchmarking tools and a limited budget seems to be the biggest obstacles.

  46. Unit Testing Performance in Java Projects: Are We There Yet? Performance tests are in less than 3 % of Java projects (functional tests are present in about one third). The existing tests are not suitable for build-time testing (complex setup, limited budget, little pressure to do so). Complexity of the benchmarking tools and a limited budget seems to be the biggest obstacles. http://d3s.mff.cuni.cz/resources/icpe2017/ Thank you!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend