Links

Performance

Every wrapper has some overhead. We do our best to make this number as small as possible. One unique ACF View/Card 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 View

/**
* Goal: check overhead of using the ACF 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 View 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 Views = 9 MS per View)
*/
add_shortcode('view-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_views view-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 View in ms: %s</h3>', $overheadForOneViewInMs)
. sprintf('<h3>Overhead for one View in percentages: %s</h3>', $overheadForOneViewInPercentages);
});

Test of Card

/**
* Goal: check overhead of using the ACF Cards (shortcode) way comparing with the clear code way
*
* Test: Query and render 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 no internal WP/ACF cache in the test)
*
* Result: overhead for one Card is 10 MS (147%)
* (31 MS for the shortcode way VS 21 MS for the clear code way. 31 MS - 21 MS = 10 MS)
*
* Note : Though Card uses View to render, common overhead is much lower than View's overhead * amount of posts in the results,
* because our plugin has internal cache and View's data & markup is cached.
* It means work by markup creation is done only once regardless of count of posts in Card's results.
*/
add_shortcode('card-test', function () {
$shortcodeMarkup = '';
$codeMarkup = '';
​
$shortcodeStartTime = microtime(true);
$shortcodeMarkup .= do_shortcode(' [acf_cards card-id="1129"]');
$timeForShortcode = microtime(true) - $shortcodeStartTime;
$timeForShortcodeInMs = round($timeForShortcode * 1000);
​
$codeStartTime = microtime(true);
$queryArgs = [
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_page' => 4,
'order' => 'ASC',
'orderby' => 'none',
'post__in' => [
2170,
2172,
2174,
2176
]
];
$query = new \WP_Query($queryArgs);
$codePostIds = $query->get_posts();
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);
​
$overheadForOneCardInMs = round(($timeForShortcode - $timeForCode) * 1000);
$overheadForOneCardInPercentages = round(($timeForShortcode / $timeForCode) * 100);
​
return $codeMarkup . sprintf('<h3>Time for query & display 4 posts with code in ms: %s</h3>', $timeForCodeInMs)
. $shortcodeMarkup . sprintf(
'<h3>Time for query & display 4 posts with shortcode in ms: %s</h3>',
$timeForShortcodeInMs
)
. sprintf('<h3>Overhead for one Card in ms: %s</h3>', $overheadForOneCardInMs)
. sprintf('<h3>Overhead for one Card in percentages: %s</h3>', $overheadForOneCardInPercentages);
});