Identifing Bottlenecks with Instant Profiling April 19, 2018

View all articles from Gyroscope Development Blog

Potentially slow SQL queries that are deeply buried in your application code can now be conveniently revealed by the DB profiling functions in Gyroscope 13.6.

The database wrapper, sql.php, detects the presence of a global $gsdbprofile array, if defined, the call time of each query is registered. The result can either be printed as-is, or rendered with the dumpgsdbprofile function, which is defined in forminput.php.

Here is an example scenario:

<?php

include 'icl/showsub1.inc.php';

include 'icl/showsub2.inc.php';

include 'icl/showsub3.inc.php';

function showrecord(){

    showsub1();

    showsub2();

    showsub3();

}

Instead of combing through each file, the queries can be profiled with the following changes:

function showrecord(){

    global $gsdbprofile; $gsdbprofile=array();

    showsub1();

    showsub2();

    showsub3();

    dumpgsdbprofile(true);

}

The dumpgsdbprofile function takes an optional parameter to rank the queries by running time. In addition to watching out for long running queries, also check the total number of queries, as they may point out to short-running queries that are in a loop structure; the total querying time still sums up to a slow response.

Happy optimizing!

Our Services

Targeted Crawlers

Crawlers for content extraction, restoration and competitive intelligence gathering.

Learn More

Gyroscope™ ERP Solutions

Fully integrated enterprise solutions for rapid and steady growth.

Learn More

E-Commerce

Self-updating websites with product catalog and payment processing.

Learn More
Chat Now!
First Name*:
Last Name*:
Email: optional