Home Forums Add-ons Repeater Field How to improve performance on add_row() for repeater field Reply To: How to improve performance on add_row() for repeater field

  • Thank you John for your comments.

    Yes, there might be other ways to accomplish this but repeater is the natural one here.

    What makes me believe that there might be something else at play is the fact that the time it takes to process the add_row() function increases exponentially as the number of iterations grow (and the same is true for delete_row() ).

    I ran some tests with 150, 300, 500, 700 and 1000 iterations (for each quantity I ran it at least 3 times and this is the average). I’ve placed timers just before and just after the add_row and delete_row loop, just to be sure nothing else was impacting them. Here are the results I got:

    150 – add_row: 15s (100ms per record) – delete_row: 10s (067ms per record)
    300 – add_row: 45s (150ms per record) – delete_row: 36s (120ms per record)
    500 – add_row: 1m52s (230ms per record) – delete_row: 1m30s (180ms per record)
    700 – add_row: 3m13s (276ms per record) – delete_row: 2m52s (245ms per record)
    1000 – add_row: 7m32s (452ms per record) – delete_row: 6m24s (385ms per record)

    The numbers themselves are not important (the time will depend on many variables, including server setup, connection, etc). But the fact that the time per record grows exponentially is what confuses me.

    I was just hoping that someone would tell me that this is either the normal behaviour for ACF’s add_row and delete_row or that I’m missing something (like a flag or another function or parameter)…