public static function render()
    {
        ?>
        <div class="input-group input-group-sm input-group-symbol">
            <span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span>
            <table class="input-suggestions">
            </table>
            <input class="form-control input-group-sm" style="width:20vw;" name="search"
                   placeholder="Search Functions Here" autocomplete="off" type="text" list="symbols">

        </div>

        <?php 
        if (CurrentPage::getParam('symbol')) {
            ?>
        <a class="btn btn-primary btn-sm" href="<?php 
            echo CurrentPage::url(array('symbol' => ''));
            ?>
">
            <span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
            View Top Level Run Report
        </a>
        <?php 
        }
    }
Exemplo n.º 2
0
    public static function render($runData, $sqlData)
    {
        ?>
<!DOCTYPE HTML><html>
        <?php 
        HtmlHead::render('SQL Queries - ' . $runData['namespace'] . ' - SugarCRM XHProf Viewer', array('xhprof/css/xhprof.css', 'bower_components/bootstrap/dist/css/bootstrap.min.css', 'bower_components/highlightjs/styles/default.css', 'bower_components/font-awesome/css/font-awesome.min.css', 'xhprof/css/run-page.css'), array('bower_components/jquery/dist/jquery.min.js', 'bower_components/bootstrap/dist/js/bootstrap.min.js', 'bower_components/highlightjs/highlight.pack.min.js', 'xhprof/js/queries.js', 'bower_components/lexer/lexer.js', 'xhprof/js/sql-formatter.js'));
        ?>
        <body class="container-fluid">
        <div>
            <div class="page-header form-inline" style="margin-top: 20px;">

                <div class="navbar-form pull-right" style="padding-right:0;">
                    <a class="btn btn-default btn-overall-summary">
                        <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
<!--                        <div>--><?php 
        //static::renderOverallSummary();
        ?>
<!--</div>-->
                    </a>
                    <a class="btn btn-primary" href="<?php 
        echo htmlspecialchars(CurrentPageHelper::getParam('list_url'));
        ?>
">
                        <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> Back To List
                    </a>
                </div>
                <h1><p>SugarCRM XHProf Viewer </p><small><?php 
        echo htmlspecialchars($runData['namespace']);
        ?>
</small></h1>
            </div>
        </div>

        <?php 
        TopTabsTemplate::render($runData);
        ?>
        <?php 
        SqlQueriesTableTemplate::render('SQL Queries', $sqlData, 'sql');
        ?>

        <script type="text/javascript">
            $(function () {
                $('[data-toggle="tooltip"]').tooltip({html: true})
            });
        </script>
        </body>
        </html><?php 
    }
Exemplo n.º 3
0
    public static function render()
    {
        ?>
        <thead>
            <tr>
                <?php 
        foreach (static::getColumns() as $column => $meta) {
            ?>
                    <th <?php 
            if (!empty($meta['percentage'])) {
                ?>
colspan="2"<?php 
            }
            ?>
>
                        <a href="<?php 
            echo CurrentPageHelper::url(array('sort' => $column));
            ?>
">
                            <?php 
            echo stat_description($column);
            ?>
                            <?php 
            if (CurrentPageHelper::getParam('sort') == $column) {
                ?>
                                <i class="fa fa-sort-amount-desc" aria-hidden="true"></i>
                            <?php 
            }
            ?>
                        </a>
                    </th>
                <?php 
        }
        ?>
            </tr>
        </thead>
        <?php 
    }
Exemplo n.º 4
0
    public static function render(StorageInterface $storage, $limit, $runs, $start, $page)
    {
        ?>
<!DOCTYPE HTML><html>
        <?php 
        HtmlHead::render('List of profiler files - SugarCRM XHProf Viewer', array('xhprof/css/xhprof.css', 'bower_components/bootstrap/dist/css/bootstrap.min.css', 'bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css', 'bower_components/font-awesome/css/font-awesome.min.css'), array('bower_components/jquery/dist/jquery.min.js', 'bower_components/bootstrap/dist/js/bootstrap.min.js', 'bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js', 'xhprof/js/list.js'));
        ?>
        <body class="container-fluid">
        <form id="list-form" method="get" action="">
            <input type="hidden" id="offset_hidden" name="offset" value="<?php 
        echo CurrentPage::getParam('offset');
        ?>
" />
            <input type="hidden" id="f_sort_by" name="f_sort_by" value="<?php 
        echo CurrentPage::getParam('f_sort_by');
        ?>
" />
            <input type="hidden" id="f_sort_dir" name="f_sort_dir" value="<?php 
        echo CurrentPage::getParam('f_sort_dir');
        ?>
" />
            <div class="page-header form-inline" style="margin-top: 20px;">
                <a class="btn btn-primary pull-right" href="<?php 
        echo CurrentPage::url();
        ?>
"><i class="fa fa-refresh"></i> Refresh</a>
                <h1>SugarCRM XHProf Viewer <small>List of profiler files in
                        <select id="dir" name="dir" class="form-control">
                            <?php 
        foreach ($storage->listDirectories() as $dir => $dirName) {
            ?>
                                <option <?php 
            if ($dir == $storage->getCurrentDirectory()) {
                ?>
selected<?php 
            }
            ?>
                                        value="<?php 
            echo htmlspecialchars($dir);
            ?>
"><?php 
            echo htmlspecialchars($dirName);
            ?>
</option>
                            <?php 
        }
        ?>
                        </select>
                    </small></h1>
            </div>

            <div class="navbar-collapse collapse" id="searchbar" style="padding:0;margin-bottom:20px;">

                <div class="navbar-form navbar-right">
                    <label for="f_wt_min" style="padding-left:5px;">Min Wall Time</label>
                    <input style="width:104px" type="text" class="form-control" autocomplete="off"
                           placeholder="0" name="f_wt_min" id="f_wt_min" value="<?php 
        echo htmlspecialchars(CurrentPage::getParam('f_wt_min'));
        ?>
" />

                    <label for="date_1" style="padding-left:20px;">Date from</label>
                    <input style="width:104px" type="text" class="form-control datepicker-dropdown" data-provide="datepicker"
                           placeholder="Date From" name="f_date_from" id="date_1" value="<?php 
        echo CurrentPage::getParam('f_date_from');
        ?>
" />

                    <label for="date_2">to</label>
                    <input style="width:104px" type="text" class="form-control datepicker-dropdown" data-provide="datepicker"
                           placeholder="Date To" name="f_date_to" id="date_2" value="<?php 
        echo CurrentPage::getParam('f_date_to');
        ?>
" />

                    <button class="btn btn-default" style="margin-left:20px;" type="submit"><b>APPLY</b></button>
                </div>

                <div class="navbar-form" style="padding-left:0;">
                    <div class="form-group" style="display:inline;">
                        <div class="input-group" style="display:table;">
                            <span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
                            <input class="form-control" name="f_text" placeholder="Search Here" autocomplete="off" autofocus="autofocus" type="text"
                                   value="<?php 
        echo htmlspecialchars(CurrentPage::getParam('f_text'));
        ?>
">
                        </div>
                    </div>
                </div>
            </div>
            <?php 
        $filterValues = array("f_date_from={CurrentPage::getParam('f_date_from')}", "f_date_to={CurrentPage::getParam('f_date_to')}", "f_text={CurrentPage::getParam('f_text')}");
        $url = "?" . implode('&', $filterValues) . "&limit={$limit}";
        $sortMarker = CurrentPage::getParam('f_sort_dir') == 'desc' ? '<span class="caret"></span>' : '<span class="dropup"><span class="caret"></span></span>';
        $url .= "&offset=0";
        ?>

            <table id="tbl" class="table table-condensed table-bordered">
                <thead>
                <tr class="active">
                    <th class="align-right">#</th>
                    <th>Profile</th>
                    <th class="align-right sortable"
                    ><a href="<?php 
        echo static::thisPageFilterUrl('wt');
        ?>
"
                        >Wall Time<?php 
        echo CurrentPage::getParam('f_sort_by') == 'wt' ? $sortMarker : '';
        ?>
</a>
                    </th>
                    <th class="align-right sortable">
                        <a href="<?php 
        echo static::thisPageFilterUrl('sql');
        ?>
"
                        >SQL<?php 
        echo CurrentPage::getParam('f_sort_by') == 'sql' ? $sortMarker : '';
        ?>
</a>
                    </th>
                    <th class="align-right sortable">
                        <a href="<?php 
        echo static::thisPageFilterUrl('ts');
        ?>
"
                        >Timestamp<?php 
        echo CurrentPage::getParam('f_sort_by') == 'ts' ? $sortMarker : '';
        ?>
</a>
                    </th>
                    <th class="align-right">File Size</th>
                </tr>
                </thead>
                <tbody>

                <?php 
        $lastTestTime = 0;
        $microtime = microtime(1);
        foreach ($runs['runs'] as $index => $run) {
            if (CurrentPage::getParam('f_sort_by') == 'ts' && (!$lastTestTime || abs($run['timestamp'] - $lastTestTime) > 5)) {
                ?>
                        <tr>
                            <td colspan="7" class="align-center age-bar">
                                <?php 
                echo static::toTimePcs($microtime - $run['timestamp']);
                ?>
 ago
                            </td>
                        </tr>
                    <?php 
            }
            $lastTestTime = $run['timestamp'];
            ?>

                    <tr class="run">
                        <td class="align-right"><?php 
            echo $index + 1;
            ?>
</td>
                        <td><a title="<?php 
            echo strlen($run['namespace']) > 100 ? $run['namespace'] : '';
            ?>
"
                               href="<?php 
            echo UrlHelper::url(array('dir' => $storage->getCurrentDirectory(), 'run' => $run['run'], 'source' => 'xhprof', 'list_url' => CurrentPage::url()));
            ?>
">
                                <?php 
            $name = substr($run['namespace'], 0, 100) . '' . (strlen($run['namespace']) > 100 ? ' ...' : '');
            ?>
                                <?php 
            echo $name ? preg_replace("/" . preg_quote(CurrentPage::getParam('f_text')) . "/i", "<b style='color:black;background-color:yellow;'>\$0</b>", $name) : '-no-name-';
            ?>
                            </a>
                        </td>
                        <td class="align-right"><?php 
            echo is_null($run['wall_time']) ? '-' : number_format($run['wall_time'], 0, ' ', ' ');
            ?>
</td>
                        <td class="align-right">
                            <?php 
            echo $run['sql_queries'] === false || is_null($run['sql_queries']) ? '-' : $run['sql_queries'];
            ?>
                        </td>
                        <td class="align-right"><?php 
            echo date('Y-m-d H:i:s', $run['timestamp']);
            ?>
</td>
                        <td class="align-right"><?php 
            echo static::toBytes($run['size']);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                </tbody>
            </table>
            <div class="form-inline align-center">

                <?php 
        if ($runs['total'] > $limit) {
            $pages = ceil($runs['total'] / $limit);
            $startPage = ceil($start / $limit) + 1;
            $startPage = $startPage ?: 1;
            $pagesBefore = $startPage - 1;
            $pagesAfter = $pages - $startPage;
            if ($pagesBefore > 4) {
                $pagesBefore = $pagesAfter < 4 ? 4 + (4 - $pagesAfter) : 4;
            }
            if ($pagesAfter + $pagesBefore > 8) {
                $pagesAfter = 8 - $pagesBefore;
            }
            ?>

                    <ul class="pagination pagination-sm">
                        <?php 
            $liClass = $startPage > 1 ? '' : ' class="disabled"';
            ?>
                        <li<?php 
            echo $liClass;
            ?>
><a href="<?php 
            echo CurrentPage::url(array('offset' => 0));
            ?>
">&lt;&lt;&lt; </a></li>
                        <li<?php 
            echo $liClass;
            ?>
><a href="<?php 
            echo CurrentPage::url(array('offset' => $page - 1));
            ?>
">&lt; </a></li>

                        <?php 
            for ($i = 1; $i <= $pagesBefore; $i++) {
                ?>
                            <li><a href="<?php 
                echo CurrentPage::url(array('offset' => $startPage - ($pagesBefore - $i + 1) - 1));
                ?>
"><?php 
                echo $startPage - ($pagesBefore - $i + 1);
                ?>
</a></li>
                        <?php 
            }
            ?>

                        <li class="active"><a href="<?php 
            echo CurrentPage::url(array('offset' => $startPage - 1));
            ?>
"><?php 
            echo $startPage;
            ?>
</a></li>

                        <?php 
            for ($i = 1; $i <= $pagesAfter; $i++) {
                ?>
                            <li><a href="<?php 
                echo CurrentPage::url(array('offset' => $i + $startPage - 1));
                ?>
"><?php 
                echo $i + $startPage;
                ?>
</a></li>
                        <?php 
            }
            ?>

                        <?php 
            $liClass = $pagesAfter > 0 ? '' : ' class="disabled"';
            ?>
                        <li<?php 
            echo $liClass;
            ?>
><a href="<?php 
            echo CurrentPage::url(array('offset' => $page + 1));
            ?>
"> &gt;</a></li>
                        <li<?php 
            echo $liClass;
            ?>
><a href="<?php 
            echo CurrentPage::url(array('offset' => $pages - 1));
            ?>
"> &gt;&gt;&gt;</a></li>
                    </ul>
                    <p>Filtered: <?php 
            echo $runs['total'];
            ?>
 / Total: <?php 
            echo $runs['grand_total'];
            ?>
 / <?php 
            echo $pages;
            ?>
 pages</p>
                    <?php 
        } else {
            ?>
                    <p>Filtered: <?php 
            echo $runs['total'];
            ?>
 / Total: <?php 
            echo $runs['grand_total'];
            ?>
</p>
                <?php 
        }
        ?>

                <p>
                    Results per page:
                    <select class="form-control" id="limit" name="limit">
                        <?php 
        foreach (array(10, 50, 100, 500, 1000, 10000, 100000) as $val) {
            ?>
                            <option value="<?php 
            echo $val;
            ?>
"<?php 
            echo $val == $limit ? ' selected' : '';
            ?>
><?php 
            echo $val;
            ?>
</option>
                        <?php 
        }
        ?>
                    </select>
                </p>
                <?php 
        \Sugarcrm\XHProf\Viewer\Templates\RunsList\VersionTemplate::render();
        ?>
            </div>
        </form>
        <script type="application/javascript">
            $(function () {
                $('[data-toggle="tooltip"]').tooltip({html: true})
            });
        </script>
        </body>
        </html>

        <?php 
    }
Exemplo n.º 5
0
    public static function render($runData)
    {
        ?>
        <ul class="nav nav-tabs">
            <li role="presentation" <?php 
        if (!CurrentPageHelper::getParam('page')) {
            ?>
class="active"<?php 
        }
        ?>
>
                <a href="<?php 
        echo UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'), 'list_url' => CurrentPageHelper::getParam('list_url')));
        ?>
">Function Calls</a>
            </li>
            <li role="presentation" <?php 
        if (CurrentPageHelper::getParam('page') == 'sql') {
            ?>
class="active"<?php 
        }
        ?>
>
                <a href="<?php 
        echo UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'), 'page' => 'sql', 'list_url' => CurrentPageHelper::getParam('list_url')));
        ?>
">SQL Queries
                    <?php 
        if (isset($runData['sql_queries'])) {
            ?>
                        <span class="badge"><?php 
            echo FormatHelper::number($runData['sql_queries']);
            ?>
</span>
                    <?php 
        }
        ?>
                </a>
            </li>
            <li role="presentation" <?php 
        if (CurrentPageHelper::getParam('page') == 'elastic') {
            ?>
class="active"<?php 
        }
        ?>
>
                <a href="<?php 
        echo UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'), 'page' => 'elastic', 'list_url' => CurrentPageHelper::getParam('list_url')));
        ?>
">Elastic Queries
                    <?php 
        if (isset($runData['elastic_queries'])) {
            ?>
                        <span class="badge"><?php 
            echo FormatHelper::number($runData['elastic_queries']);
            ?>
</span>
                    <?php 
        }
        ?>
                </a>
            </li>
        </ul>
        <?php 
    }
Exemplo n.º 6
0
 protected static function typeAheadUrl()
 {
     return UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run')));
 }
    public static function renderTopButtons()
    {
        ?>
        <form method="get" class="form-inline" style="display:inline-block; margin:0">
            <?php 
        foreach (CurrentPage::getParams() as $key => $value) {
            ?>
                <input type="hidden" name="<?php 
            echo htmlspecialchars($key);
            ?>
" value="<?php 
            echo htmlspecialchars($value);
            ?>
"/>
            <?php 
        }
        ?>

            <div class="input-group input-group-sm">
                <div class="input-group-addon">/</div>
                <input type="text" class="form-control" name="regex_text" style="width: 350px" placeholder="RegEx"
                       value="<?php 
        echo htmlspecialchars(CurrentPage::getParam('regex_text'));
        ?>
">
                <div class="input-group-addon" style="border-left: 0; border-right: 0;">/</div>
                <input type="text" class="form-control" name="regex_mod" style="width: 50px" placeholder=""
                       value="<?php 
        echo htmlspecialchars(CurrentPage::getParam('regex_mod'));
        ?>
">
            </div>

            <div class="btn-group" role="group">
                <a class="btn btn-primary btn-sm <?php 
        echo CurrentPage::getParam('type') == 'all' ? 'active' : '';
        ?>
"
                   href="<?php 
        echo CurrentPage::url(array('type' => 'all'));
        ?>
">All Queries</a>
                <a class="btn btn-primary btn-sm <?php 
        echo CurrentPage::getParam('type') == 'select' ? 'active' : '';
        ?>
"
                   href="<?php 
        echo CurrentPage::url(array('type' => 'select'));
        ?>
">Selects</a>
                <a class="btn btn-primary btn-sm <?php 
        echo CurrentPage::getParam('type') == 'modify' ? 'active' : '';
        ?>
"
                   href="<?php 
        echo CurrentPage::url(array('type' => 'modify'));
        ?>
">Inserts/Updates</a>
                <a class="btn btn-primary btn-sm <?php 
        echo CurrentPage::getParam('type') == 'other' ? 'active' : '';
        ?>
"
                   href="<?php 
        echo CurrentPage::url(array('type' => 'other'));
        ?>
">Others</a>
            </div>

            <div class="btn-group" role="group">
                <a class="btn btn-primary btn-sm <?php 
        echo CurrentPage::getParam('sort_by') == 'time' ? 'active' : '';
        ?>
"
                   href="<?php 
        echo CurrentPage::url(array('sort_by' => 'time'));
        ?>
">Sort by Time</a>
                <a class="btn btn-primary btn-sm <?php 
        echo CurrentPage::getParam('sort_by') == 'hits' ? 'active' : '';
        ?>
"
                   href="<?php 
        echo CurrentPage::url(array('sort_by' => 'hits'));
        ?>
">Sort by Hits</a>
                <a class="btn btn-primary btn-sm <?php 
        echo CurrentPage::getParam('sort_by') == 'exec_order' ? 'active' : '';
        ?>
"
                   data-toggle="tooltip" title="Sort in Execution Order"
                   href="<?php 
        echo CurrentPage::url(array('sort_by' => 'exec_order'));
        ?>
">Exec. Order</a>
            </div>

            <input type="submit" style="display:none;"/>
        </form>

        <?php 
    }
Exemplo n.º 8
0
 protected static function callgraphUrl($symbol)
 {
     return UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'), 'func' => $symbol));
 }
Exemplo n.º 9
0
/**
 * Generates a tabular report for all functions. This is the top-level report.
 *
 * @author Kannan
 */
function full_report($url_params, $symbol_tab)
{
    $callgraph_report_title = '<i class="fa fa-pie-chart"></i> View Full Callgraph';
    $callGraphUrl = \Sugarcrm\XHProf\Viewer\Templates\Helpers\UrlHelper::url(array('callgraph' => 1, 'dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run')));
    $callGraphButton = '<a class="btn btn-primary btn-sm" target="_blank" href="' . $callGraphUrl . '">' . $callgraph_report_title . '</a>';
    $flat_data = array();
    foreach ($symbol_tab as $symbol => $info) {
        $tmp = $info;
        $tmp["fn"] = $symbol;
        if (!isset($tmp['bcc'])) {
            $tmp['bcc'] = '';
        }
        $flat_data[] = $tmp;
    }
    usort($flat_data, 'sort_cbk');
    if (!empty($url_params['all'])) {
        $limit = 0;
        // display all rows
    } else {
        $limit = 100;
        // display only limited number of rows
    }
    print_flat_data('Top-Level Report &nbsp;', $flat_data, $limit, $callGraphButton);
}