Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Tareq Hasan

    (@tareq1988)

    Where did you find 150 queries?

    Oh my gawd!!

    Yes it’s TimeBusters Inc leaping into action!

    With our powerful eXtrA-Ray technology we have managed to peel back the core of WordPress and WPUF to reveal the time machinations and have found this!

    blank post 64 queries, pagetime= 0.282 seconds
    dashboard 118 queries, pagetime= 0.358 seconds
    add post 113 queries, pagetime= 0.320 second
    edit post 122 queries, pagetime= 0.354 seconds

    Oh no looks like were missing milliseconds here. Thief!!!Thief!!!

    Ummmmm…Looks like there’s too many options and our thief has been taking his time picking thru them.

    Time to lay a trap….

    $wpuf_prepared_fields = '';
    
    /**
     * Get the value of a settings field
     *
     * @param string $option option field name
     * @return mixed
     */
    function wpuf_get_option( $option ) {
    	global $wpuf_prepared_fields;
    
    	if ( !empty( $wpuf_prepared_fields ) )
    	{
    		$prepared_fields = $wpuf_prepared_fields;
    	}
    	else
    	{
    		$fields = wpuf_settings_fields();
    
    		$prepared_fields = array();
    
    		//prepare the array with the field as key
    		//and set the section name on each field
    		foreach ($fields as $section => $field) {
    			foreach ($field as $fld) {
    				$prepared_fields[$fld['name']] = $fld;
    				$prepared_fields[$fld['name']]['section'] = $section;
    			}
    		}
    
    		$wpuf_prepared_fields = $prepared_fields;
    	}
    ......

    ……Gotcha!!!

    blank 54 queries(3.5ms), pagetime= 0.246 seconds
    dashboard 72 queries(18.3ms), pagetime= 0.308 seconds
    add post 54 queries(4.6ms), pagetime= 0.245 seconds
    edit post 63 queries(5.5ms), pagetime= 0.257 seconds

    Ahhh another case sucessfully solved by TimeBusters Inc.

    Here at Timebusters we believe that time is money and at our special rate of $1000 per millisecond we believe we are a bargain. So we are sure you will find our total invoice for $50000 for your 50ms saving more than value for money.

    PS James Gleick’s book ‘Faster: The Acceleration of Just About Everything’. It taken me 3 years to rid so far and I aint finished yet.

    Plugin Author Tareq Hasan

    (@tareq1988)

    @professor99, I don’t think thats the issue. Are you clear whats going on here? It’s just a loop of array to be prepared, no database query is executed. After preparing the array, a single get_option() is being called. So how this can be expensive?

    There are a couple of functions calls by the array construction in wpuf_settings_fields(). The thief is hiding in wpuf_list_users(). He is only a petty thief with a penchant for pinching milliseconds as shown above. Without my cache this is called for each option so it adds up. However it only adds up to 50ms which is nothing unless your a penny pinching miser :).

    PS The WordPress plugin “Debug Bar” and it’s accompanying plugin “Debug Bar Console” are a great way of monitoring SQL queries. Just add define(‘SAVEQUERIES’, true); to your wp-config.php file and it will show you all your SQL queries along with the function call stack for each. Makes tracking problems like this a cinch.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘fantastic idea. but…unusable.’ is closed to new replies.