For the complete documentation index, see llms.txt. This page is also available as Markdown.

Performance

Every wrapper has some overhead. We do our best to make this number as small as possible. One unique Layout or Post Selection on a page would only effect this by 0.01 seconds* overhead compared to the usual way with coding. It’s impossible to notice these tiny numbers visually without testing it.

*This number was given by our tests, codes of the tests are provided below. Numbers can be different depending on your hosting opportunities.

Test of a Layout

/**
 * Goal: check overhead of using the Advanced Views (shortcode) way comparing with the clear code way without any caching
 *
 * Test: Render of 4 post (1 post field + 4 ACF fields) for each way (clear code/shortcode)
 * (every way has its own posts and own ACF Group per each post, so there is totally no internal cache in the test)
 *
 * Result: overhead for one Layout is 9 MS (14 MS per post for the shortcode way VS 5 MS per post for the clear code way, 280%)
 * (55 MS for the shortcode way VS 20 MS for the clear code way. (55 MS - 20 MS) / 4 Layouts = 9 MS per Layout)
 */
add_shortcode('layout-test', function () {
    $shortcodePostIds = [1093, 2012, 2014, 2016,];
    $viewIds          = [895, 2087, 2088, 2089];
    $codePostIds      = [2170, 2172, 2174, 2176,];
    $shortcodeMarkup  = '';
    $codeMarkup       = '';

    $shortcodeStartTime = microtime(true);
    for ($i = 0; $i < 4; $i++) {
        $shortcodeMarkup .= do_shortcode(
            sprintf(
                '[acf-layout id="%s" object-id="%s"]',
                $viewIds[$i],
                $shortcodePostIds[$i]
            )
        );
    }
    $timeForShortcode     = microtime(true) - $shortcodeStartTime;
    $timeForShortcodeInMs = round($timeForShortcode * 1000);

    $codeStartTime = microtime(true);
    foreach ($codePostIds as $codePostId) {
        $postTitle = get_the_title($codePostId);
        // Text
        $description = get_field('description2', $codePostId);
        // Date Picker d/m/Y
        $year = get_field('year2', $codePostId);
        // Wysiwyg Editor
        $longDescription = get_field('long_description2', $codePostId);
        // Number
        $price = get_field('price2', $codePostId);

        $codeMarkup .= '<div class="acf-view acf-view--id--895 acf-view--object-id--{object-id}">';

        $codeMarkup .= '<div class="acf-view__row _post_title">';
        $codeMarkup .= sprintf('<div class="acf-view__field">%s</div>', $postTitle);
        $codeMarkup .= '</div>';

        $codeMarkup .= '<div class="acf-view__row description">';
        $codeMarkup .= sprintf('<div class="acf-view__field">%s</div>', $description);
        $codeMarkup .= '</div>';

        $codeMarkup .= '<div class="acf-view__row year">';
        $codeMarkup .= sprintf('<div class="acf-view__field">%s</div>', $year);
        $codeMarkup .= '</div>';

        $codeMarkup .= '<div class="acf-view__row long_description">';
        $codeMarkup .= sprintf('<div class="acf-view__field">%s</div>', $longDescription);
        $codeMarkup .= '</div>';

        $codeMarkup .= '<div class="acf-view__row price">';
        $codeMarkup .= sprintf('<div class="acf-view__field">%s</div>', $price);
        $codeMarkup .= '</div>';


        $codeMarkup .= '</div>';
    }
    $timeForCode     = microtime(true) - $codeStartTime;
    $timeForCodeInMs = round($timeForCode * 1000);

    $overheadForOneViewInMs          = round((($timeForShortcode / 4) - ($timeForCode / 4)) * 1000);
    $overheadForOneViewInPercentages = round((($timeForShortcode / 4) / ($timeForCode / 4)) * 100);

    return $codeMarkup . sprintf('<h3>Time for 4 posts with code in ms: %s</h3>', $timeForCodeInMs)
           . $shortcodeMarkup . sprintf('<h3>Time for 4 posts with shortcode in ms: %s</h3>', $timeForShortcodeInMs)
           . sprintf('<h3>Overhead for one Layout in ms: %s</h3>', $overheadForOneViewInMs)
           . sprintf('<h3>Overhead for one Layout in percentages: %s</h3>', $overheadForOneViewInPercentages);
});

Test of a Post Selection

Last updated