Hibernate Performance Test (simple test of LOAD10000 record is for reference only)

xiaoxiao2021-03-06  41

Performance Test: Test a 9036 record table, 8 table fields, there is a field is a text type, and each record is more than 1300 bytes, and the rest is simple field hardware and software: AMD XP1600 512M memory (more memory during test), WinXP SP1, JDK1.4.2_06, MySQL4.1.9, InnoDB, GBK, MM.3.1.6 Driver, Tomcat 5.0.28 (start setting maximum memory 256M, minimum memory 64m), Hibernate2. 1.8, open the second-level cache EHCACHE (Configure 2 Cache Up to 1000 objects) Turn off all Hibernate log information and SQL output method 1: first use list idlist = session.find ("SELECT O.ID from myclass o"); IDLIST then list.add (Session.Load (MyClass.class (i)))); Composition List method 2: Get List method directly with Hibernate's session.find (from myclass): Directly use hibernate SESSION.ITERATOR (from myclass), then list = new arraylist (9100); while (ore.hasnext ()) {list.add ());} Constructing List Each method is continuously called 5 times. (The first call is the result of the second-level cache, and the results of the secondary cache are followed: End the first loadall1 () method, end the second loadall1 () method, the second loadall1 () method, At the end of 771 ms ~ 580ms, the 3rd loadall1 () method is ended, and the fourth loadall1 () method is ended with time 631 ms ~ 611 ms, and the 5th Loadall1 () method is ended with time 641 ms ~ 591ms, and the first time 601 ms ~ 551 ms ends LOADALL2 () Method, the second loadall2 () method is ended with 2965 ms ~ 3025ms, and the third Loadall2 () method is ended with time 2613 ms ~ End 4613 ms ~ End the 4th loadall2 () method, with time 2815 ms ~ End 5 times load2 () Method, use 2653ms ~ End Loadall3 () method, end the second loadall3 () method at the time of 16664ms ~ 16514 ms, and end the third loadall3 () method for 651 ms ~ 661 ms, and the time 621 ms ~ 591 ms ends the fourth Loadall3 ( ) Method, end the 571 ms ~ 571ms to end the 5th loadall3 () method, use the time 641MS ~ 631MS

Analysis: Method 1 and Method 3 are the same as the policy of accessing the database, so the running time is substantially almost. (Method 3 is slightly slower, it may be that it is more time for Iterator traverses to form LIST.) These two methods are running 9036 1 time database access, so the longest time. After the second time, run only the database and only take out the ID of the data ID, because all objects already have a secondary cache, and the remaining is the access to the secondary cache composition List, so speed The fastest. Method 2 Every time you visit all fields of the database load, open the Cache's log information, you can see that the second class will get data through the secondary cache, but because the LOAD all field occupation time accounts for a large proportion. Overhead, so even if you access the second-level cache, performance improvement is very small, and it costs almost the same time. Note: (1) Do not run Tomcat after the machine is running for a long time, especially after the machine starts frequent Tomcat, Java programs, and open larger applications to take a lot of memory. At that time the test results must be allowed. For example: I tested last night, the time used by the method 1 was 200 s, 60s, and then runs the method 2. I used 8000S, 200S! (2) to set the log4j LOG level, not Hibernate and SQL information. Time will decrease a lot. (Log4j's configuration file has this rule: said that the end does not have spaces ??? ft !!!) (3) Test when Tomcat starts, and calls a method of hibernate before testing, let Hibernate initialization first completed

转载请注明原文地址:https://www.9cbs.com/read-58518.html

New Post(0)