Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11661

Where should I look for performance issues when number and time of queries and memory don't change?

$
0
0

I'm a little new to php performance testing. I'm debugging a custom wordpress theme (made by me) and I've got a page that is too slow. The page loads something like 250 posts. Each of them has several custom fields (acf pro). I've found a couple of function that query for acf values are the bottleneck. In particular, there's one that, inside the wp loop, will raise the page loading time of about 1 second.

The problem is that, it's only that: I mean, the only thing that changes is page load time (even without rendering nothing), but total query time, memory peak and number of queries doesn't changes that much. Very little. Using Query Monitor plugin for measures.

The function is very simple, like:

public function get_field_value($field, $use_filtered_fields = true, $raw_value = false, $post_id = null, $lang = null){    if(!$post_id) return null;    if($lang) $t_post_id = pll_get_post($post_id, $lang); // Polylang query, not always used    $pid = (!empty($t_post_id)) ? $t_post_id : $post_id;    $field_metadata = $this->fields_metadata[$field]; // fields_metadata is just an array    $field_group_name = $field_metadata['group'];    $field_group = get_field($field_group_name, $pid); // ACF query    $field_value = $field_group[$field];    if(isset($field_metadata['datatype']) && !$raw_value){      if($field_metadata['datatype'] == 'file'&& $field_metadata['subtype'] == 'pdf'){        if(isset($field_value['url'])) return $field_value['url'];      }    }    return $field_value;}

As you can see it only queries for an ACF field and for the rest is just 'static' array access, so I don't know why its so slow. Other than being called 250 times (about the number of posts I'm currently testing).

So my question is: when some code only affects page load but not memory usage, nor total query time or total number of queries, where should I look at? Where should I look to find the reason of raised page load time (again: no rendering here for now, no js, no html, only code 'computation')?


Viewing all articles
Browse latest Browse all 11661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>