benchmarking - Convert List<Integer> to int[] - Pure Java vs ArrayUtils benchmark issue -


i had optimise api call in high performance system did list<integer> int[] conversion. initial finding expected average amount of elements pure java seemed lot faster used apache commons arrayutils. factor 100-200 , sort of amazed. problem ran test on 1 pair of conversions @ time, restarting little test program each number of elements wanted test. doing that, pure java way faster number of elements several k's started out. sat down write nicer test program runs , outputs results number of different sized lists in 1 go , results quite different.

it seems arrayutils slower on first run, faster on subsequent runs regardless of list size, , regardless of number of element on first run.

you can find test class here: http://pastebin.com/9eylzqkv

please me pick holes in it, don't why output get.

many thanks!

you need account loading times , warmup in code. built in classes may called first , may loaded, , warmed up.

a loop not optimised until has been run @ least 10,000 times. if don't know when suggest running code @ least half second 2 seconds before starting timing. suggest repeating test @ least 2 10 seconds , average results.

btw fastest way convert list<integer> int[] avoid needing convert in first place. if use tintarraylist or it, can use same structure without copying or converting.


Popular posts from this blog

Php - Delimiter must not be alphanumeric or backslash -

Delphi interface implements -

java - How to create Table using Apache PDFBox -