Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.3.3 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "interconnectit/plugin-icit-profiler",
"type": "wordpress-plugin",
"homepage": "https://github.com/interconnectit/plugin-icit-profiler",
"authors": [
{
"name": "interconnect/it",
"email": "[email protected]",
"homepage": "https://interconnectit.com/"
}
],
"require": {
"php": ">=5.6",
"composer/installers": "~1.0"
}
}
6 changes: 3 additions & 3 deletions load-wp-performance-profiler.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* Author: Damian Gostomski
* Author URI: http://interconnectit.com
* Description: Pinpoint slow parts of your site, so that you can make them faster.
* Version: 0.3
* Version: 0.3.2
*
* This file exists to make installing this as a mu-plugin as easy as possible, and also works for regular plugins.
*/

! defined( 'ICIT_PERFORMANCE_PROFILER_LOADER_FILE' ) && define( 'ICIT_PERFORMANCE_PROFILER_LOADER_FILE', plugin_basename( __FILE__ ) );
!defined('ICIT_PERFORMANCE_PROFILER_LOADER_FILE') && define('ICIT_PERFORMANCE_PROFILER_LOADER_FILE', plugin_basename(__FILE__));

require_once 'wp-performance-profiler/index.php';
require_once __DIR__ . '/wp-performance-profiler/wp-performance-profiler.php';
24 changes: 24 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Icit Profiler

## Requirements

Make sure all dependencies have been installed before moving on:

* [PHP 5.6](http://php.net/manual/en/install.php)
* [Composer](https://getcomposer.org/download/)

## Install

Add the following to the projects composer.json file:

``` json
"repositories": [
{
"type": "git",
"url": "[email protected]:interconnectit/plugin-icit-profiler.git"
}
],
"require": {
"interconnectit/plugin-icit-profiler": "dev-master"
}
```
13 changes: 6 additions & 7 deletions readme.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: gostomski, interconnectit
Tags: performance, optimisation, profiler, plugins, speed
Requires at least: 4.0.1
Tested up to: 4.9
Stable tag: 0.4
Tested up to: 4.3
Stable tag: 0.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -21,6 +21,9 @@ The WordPress Performance Profiler will monitor the performance of your site and

== Installation ==

Please note that you will need PHP 5.3 or above to be able to run this plugin
and we recommend you are using production sites on at least PHP 5.5 or above.

To install the WordPress Performance Profiler as a must-use plugin (recommended):

1. If you don't already have have a folder called `mu-plugins` inside your wp-content directory, create it
Expand Down Expand Up @@ -70,16 +73,12 @@ Yes, although this plugin is primarily meant as a developer tool - so is most be

If you are going to run it in a production environment, it's recommended to set the advanced logging level to a very low number, and the basic level to a low-medium number. With a large amount of traffic, this will still capture a lot of data with minimal overhead. If you run it with higher values (especially for the advanced logging), you'll need to periodically purge the database in the maintenance tab.

= Can I manually log requests =
= Can I manually log requests? =

If you don't want to run the profiler all the time, or only want to log specific requests, you can manually log them by adding `?profiler` to the query string. This will enable the advanced profiler, but if you want just basic logging, add `?profiler=basic`.
By using the query string, you will override any default settings.

== Changelog ==
= 0.4.0 =
* First new version since fork
* Fix for memory usage not displaying correctly in certain cases
* Minor hook tweaks

= 0.3.0 =
* Added ability to view plugins ordered by average duration, minimum duration, maximum duration and standard deviation
Expand Down
Empty file modified wp-performance-profiler/admin/database.php
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions wp-performance-profiler/admin/index.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,16 @@ public function admin_notices() {
</div>
<?php
endif;

//
if ( ( version_compare( PHP_VERSION, '7.0.0', '>=' ) && version_compare( PHP_VERSION, '7.2.0', '<' ) ) || defined( 'HHVM_VERSION' ) ): ?>
<div class="notice notice-error">
<p>
<strong>Oops!</strong>
WP Performance Profiler doesn't work with PHP7.0 or 7.1 or HHVM.
</p>
</div>
<?php endif;
}

private function is_tab_active( $tab ) {
Expand Down
Empty file modified wp-performance-profiler/admin/maintenance.php
100644 → 100755
Empty file.
Empty file modified wp-performance-profiler/admin/settings.php
100644 → 100755
Empty file.
Empty file modified wp-performance-profiler/assets/css/admin.css
100644 → 100755
Empty file.
Empty file modified wp-performance-profiler/assets/js/admin.js
100644 → 100755
Empty file.
12 changes: 0 additions & 12 deletions wp-performance-profiler/classes/helpers.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,4 @@ public static function has_details( $request_id ) {

return isset( $requests[ $request_id ] );
}

public static function get_memory_usage() {
if ( function_exists( 'memory_get_peak_usage' ) ) {
$memory_usage = memory_get_peak_usage();
} elseif ( function_exists( 'memory_get_usage' ) ) {
$memory_usage = memory_get_usage();
} else {
$memory_usage = 0;
}

return $memory_usage;
}
}
121 changes: 64 additions & 57 deletions wp-performance-profiler/classes/logger-advanced.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -134,74 +134,81 @@ public function save() {
// Although this information could be computed from the function calls when doign reporting
// It would suffer a huge performance hit due to the large number of records there
// And this also allows for an intermediate level of logging in the future, where we just store plugin level stats
$table = $wpdb->prefix . 'profiler_plugins';
$schema = array(
'request_id' => '%d',
'plugin' => '%s',
'count' => '%d',
'duration' => '%f',
);
$data = array();

foreach( $this->stats as $plugin ) {
$data[] = array(
'request_id' => $request_id,
'plugin' => $plugin['plugin'],
'count' => $plugin['count'],
'duration' => $plugin['duration'],
if ( $this->stats ) {
$table = $wpdb->prefix . 'profiler_plugins';
$schema = array(
'request_id' => '%d',
'plugin' => '%s',
'count' => '%d',
'duration' => '%f',
);
$data = array();
foreach ( $this->stats as $plugin ) {
$data[] = array(
'request_id' => $request_id,
'plugin' => $plugin['plugin'],
'count' => $plugin['count'],
'duration' => $plugin['duration'],
);
}
if ( $data ) {
$this->bulk_insert( $table, $schema, $data );
}
}

$this->bulk_insert( $table, $schema, $data );

// We'll also store all the database queries and link them to this request
$table = $wpdb->prefix . 'profiler_queries';
$schema = array(
'request_id' => '%d',
'duration' => '%f',
'plugin' => '%s',
'the_query' => '%s',
'stack' => '%s',
);
$data = array();
foreach( $wpdb->queries as $query ) {
$data[] = array(
'request_id' => $request_id,
'duration' => $query[1] * 1000,
'plugin' => $this->get_plugin_from_query( $query[0] ),
'the_query' => $query[0],
'stack' => $query[2],
if ( $wpdb->queries ) {
$table = $wpdb->prefix . 'profiler_queries';
$schema = array(
'request_id' => '%d',
'duration' => '%f',
'plugin' => '%s',
'the_query' => '%s',
'stack' => '%s',
);

$this->time_database += $query[1] * 1000;
}

$this->bulk_insert( $table, $schema, $data );

// Then, we'll store the detailed logs for each function
$table = $wpdb->prefix . 'profiler_functions';
$schema = array(
'request_id' => '%d',
'plugin' => '%s',
'function' => '%s',
'count' => '%d',
'duration' => '%f',
);
$data = array();

foreach( $this->stats as $plugin ) {
foreach( $plugin['functions'] as $function ) {
$data = array();
foreach ( $wpdb->queries as $query ) {
$data[] = array(
'request_id' => $request_id,
'plugin' => $plugin['plugin'],
'function' => $function['function'],
'count' => $function['count'],
'duration' => $function['duration'],
'duration' => $query[1] * 1000,
'plugin' => $this->get_plugin_from_query( $query[0] ),
'the_query' => $query[0],
'stack' => $query[2],
);

$this->time_database += $query[1] * 1000;
}
if ( $data ) {
$this->bulk_insert( $table, $schema, $data );
}
}

$this->bulk_insert( $table, $schema, $data );
// Then, we'll store the detailed logs for each function
if ( $this->stats ) {
$table = $wpdb->prefix . 'profiler_functions';
$schema = array(
'request_id' => '%d',
'plugin' => '%s',
'function' => '%s',
'count' => '%d',
'duration' => '%f',
);
$data = array();
foreach ( $this->stats as $plugin ) {
foreach ( $plugin['functions'] as $function ) {
$data[] = array(
'request_id' => $request_id,
'plugin' => $plugin['plugin'],
'function' => $function['function'],
'count' => $function['count'],
'duration' => $function['duration'],
);
}
}
if ( $data ) {
$this->bulk_insert( $table, $schema, $data );
}
}

// Insert the detailed information for this request
$table = $wpdb->prefix . 'profiler_details';
Expand Down
2 changes: 1 addition & 1 deletion wp-performance-profiler/classes/logger-base.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public function save_request() {
$data = array(
'timestamp' => time(),
'duration' => $now - $this->start,
'memory' => memory_get_usage( true ),
'queries' => get_num_queries(),
'request' => $_SERVER['REQUEST_URI'],
'memory' => Helpers::get_memory_usage(),
'template' => $this->template,
'type' => icit_profiler_current_request_type(),
'payload' => $payload,
Expand Down
8 changes: 5 additions & 3 deletions wp-performance-profiler/classes/logger-basic.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ public function __construct() {

public function save() {
global $wpdb;

// Save the base request
$request_id = $this->save_request();

// We need to save the duration of DB queries as well
$database_duration = 0;
foreach( $wpdb->queries as $query ) {
$database_duration += $query[1] * 1000;
if ( $wpdb->queries ) {
foreach ($wpdb->queries as $query) {
$database_duration += $query[1] * 1000;
}
}

$table = $wpdb->prefix . 'profiler_details';
Expand Down
Empty file modified wp-performance-profiler/classes/pagination.php
100644 → 100755
Empty file.
Empty file modified wp-performance-profiler/compatibility.php
100644 → 100755
Empty file.
Loading