Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Array copy is a rather unexpensive operation. It is done on a very basic level (its a java native static method) and you are not yet in the range where the performance becomes really important. </p> <p>In your example you copy approx 12000 times an array of size 150000 (on average). This does not take much time. I tested it here on my laptop and it took less than 500 ms.</p> <p><strong>Update</strong> I used the following code to measure on my laptop (Intel P8400)</p> <pre><code>import java.util.Random; public class PerformanceArrayCopy { public static void main(String[] args) { int[] lengths = new int[] { 10000, 50000, 125000, 250000 }; int[] loops = new int[] { 1000, 5000, 10000, 20000 }; for (int length : lengths) { for (int loop : loops) { Object[] list1 = new Object[length]; Object[] list2 = new Object[length]; for (int k = 0; k &lt; 100; k++) { System.arraycopy(list1, 0, list2, 0, list1.length); } int[] len = new int[loop]; int[] ofs = new int[loop]; Random rnd = new Random(); for (int k = 0; k &lt; loop; k++) { len[k] = rnd.nextInt(length); ofs[k] = rnd.nextInt(length - len[k]); } long n = System.nanoTime(); for (int k = 0; k &lt; loop; k++) { System.arraycopy(list1, ofs[k], list2, ofs[k], len[k]); } n = System.nanoTime() - n; System.out.print("length: " + length); System.out.print("\tloop: " + loop); System.out.print("\truntime [ms]: " + n / 1000000); System.out.println(); } } } } </code></pre> <p>Some results:</p> <pre><code>length: 10000 loop: 10000 runtime [ms]: 47 length: 50000 loop: 10000 runtime [ms]: 228 length: 125000 loop: 10000 runtime [ms]: 575 length: 250000 loop: 10000 runtime [ms]: 1198 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload