java - Why does my server initialize substantially slower in JUnit then when run stand-alone -
i have server want automated functional tests on. needs initialize few thousand total objects build it's in memory model, fetching data config files, still trivial computer , it's near-instantaneous bootup when run eclipse.
when run same program part of junit test initialization phase takes 15 seconds or instead of instantaneous speed of stand-alone app. not long, if plan many dozens of tests add up.
according jvisualvm time spread out on half dozen methods, no 1 method taking longer 14% of cpu time (this after optimized away method taking 50% of cpu). of methods running methods expect see running , seem taking reasonable percentage of total cpu time; can't compare live server because live server initializes fast can't start , stop jvisualvm fast enough profile it. seem if the init methods of objects may take longer, instance 1 object uses 3% cpu init, has self time of 000 ms , makes no other calls; don't know if that's common result using jvisualvm?
though shouldn't matter doing 1 thing differently in junit vs running stand-alone app; i'm using servermock object (though it's hardly mock atm). extends server object. right reason extend because server's run method (which runs indefinitely waiting incoming messages) protected method called main() method when server run jar. mock adds method spawn thread run server's run method since have no other way of starting method in unit test. however, slow down in initialization of server before gets run method; don't think cause of slowdown?
Comments
Post a Comment