From: Tatu S. <cow...@ya...> - 2007-03-19 19:19:39
|
--- Fernando Gonzalez <fer...@gm...> wrote: > Well, jeje, the computer is new but I don't think my > disk is so fast. I > think Java or the operating system has to cache > something because the first > time I load the file it takes a bit more than 2 > seconds and after the first > load, it only takes 300ms to read the file... > I have no experience on doing benchmarks and maybe > I'm am missing something. > That's why I attached the program. One thing you need to know is that JVM's HotSpot does incremental optimization. As such, calling anything first time (or, rather, first N, where N can be like 2000 times) will take much much longer. This because code at first will be interpreted from byte code. Only after JVM notices particular part code is so-called "hot spot" (called so often it is where most time is spent) it will inline it to native code. Because of this, one must always ensure that there is enough of so-called warmup time to reach steady state performance. That is, unless your use case is such where you only run things once, using separate JVM instance. So it perfectly normal (and expected) that loading+parsing things first time is significantly slower than second time around. If you want to ensure it's not due to OS-level disk block caching (which also affects results), you can warm things up using different xml files: code paths should be same or similar, so HotSpot will optimize code, but data is different, so OS won't be able to cache it. Hope this helps, -+ Tatu +- ____________________________________________________________________________________ Looking for earth-friendly autos? Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center. http://autos.yahoo.com/green_center/ |