Plugin Directory

Changeset 1991341


Ignore:
Timestamp:
12/11/2018 12:53:35 AM (7 years ago)
Author:
kohashi
Message:

version 1.1 adds support for hyperdb and socket connections

Location:
wpperformancetester/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wpperformancetester/trunk/README.md

    r1284607 r1991341  
    4141
    4242> - It's always best to **BACKUP EVERYTHING** before running **ANY** new plugin or making changes to your WordPress install.
     43
     44Changelog
     45-------------
     46** 1.1 **
     47
     48Added support for hyperdb and socket connections.
     49
     50** 1.0.1 **
     51
     52Updated interface to make graphs and results more clear.
     53
     54** 1.0 **
     55
     56* Initial release
  • wpperformancetester/trunk/WPPerformanceTester_Plugin.php

    r1949947 r1991341  
    2929            if ($performTest){
    3030                //do test
     31                global $wpdb;
    3132                $arr_cfg = array();
    32                 $arr_cfg['db.host'] = DB_HOST;
    33                 $arr_cfg['db.user'] = DB_USER;
    34                 $arr_cfg['db.pw'] = DB_PASSWORD;
    35                 $arr_cfg['db.name'] = DB_NAME;
     33
     34                // We need special handling for hyperdb
     35                if ( is_a( $wpdb, 'hyperdb' ) && ! empty( $wpdb->hyper_servers ) ) {
     36                  // Grab a `write` server for the `global` dataset and fallback to `read`.
     37                  // We're not really paying attention to priority or have much in the way of error checking. Use at your own risk :)
     38                  $db_server = false;
     39                  if ( ! empty( $wpdb->hyper_servers['global']['write'] ) ) {
     40                    foreach ( $wpdb->hyper_servers['global']['write'] as $group => $dbs ) {
     41                      $db_server = current( $dbs );
     42                      break;
     43                    }
     44                  } elseif ( ! empty( $wpdb->hyper_servers['global']['read'] ) ) {
     45                    foreach ( $wpdb->hyper_servers['global']['read'] as $group => $dbs ) {
     46                      $db_server = current( $dbs );
     47                      break;
     48                    }
     49                  }
     50
     51                  if ( $db_server ) {
     52                    $arr_cfg['db.host'] = $db_server['host'];
     53                    $arr_cfg['db.user'] = $db_server['user'];
     54                    $arr_cfg['db.pw'] = $db_server['password'];
     55                    $arr_cfg['db.name'] = $db_server['name'];
     56                  }
     57                } else {
     58                  // Vanilla WordPress install with standard `wpdb`
     59                  $arr_cfg['db.host'] = DB_HOST;
     60                  $arr_cfg['db.user'] = DB_USER;
     61                  $arr_cfg['db.pw'] = DB_PASSWORD;
     62                  $arr_cfg['db.name'] = DB_NAME;
     63                }
     64               
    3665                $arr_benchmark = test_benchmark($arr_cfg);
    3766                $arr_wordpress = test_wordpress();
  • wpperformancetester/trunk/benchmark.php

    r1284607 r1991341  
    3636
    3737    $arr_return = array();
    38     $arr_return['version'] = '1.0';
     38    $arr_return['version'] = '1.1';
    3939    $arr_return['sysinfo']['time'] = date("Y-m-d H:i:s");
    4040    $arr_return['sysinfo']['php_version'] = PHP_VERSION;
     
    121121    $time_start = microtime(true);
    122122
    123     //parse out port number if exists
    124     $port = 3306;//default
    125     if(stripos($arr_cfg['db.host'],':')){
    126         $port = substr($arr_cfg['db.host'], stripos($arr_cfg['db.host'],':')+1);
    127         $arr_cfg['db.host'] = substr($arr_cfg['db.host'], 0, stripos($arr_cfg['db.host'],':'));
    128     }
    129 
    130     $link = mysqli_connect($arr_cfg['db.host'], $arr_cfg['db.user'], $arr_cfg['db.pw'], $arr_cfg['db.name'], $port);
     123
     124    //detect socket connection
     125    if(stripos($arr_cfg['db.host'], '.sock')!==false){
     126        //parse socket location
     127        //set a default guess
     128        $socket = "/var/lib/mysql.sock";
     129        $serverhost = explode(':', $arr_cfg['db.host']);
     130        if(count($serverhost) == 2 && $serverhost[0] == 'localhost'){
     131            $socket = $serverhost[1];
     132        }
     133        $link = mysqli_connect('localhost', $arr_cfg['db.user'], $arr_cfg['db.pw'], $arr_cfg['db.name'], null, $socket);
     134    }else{
     135        //parse out port number if exists
     136        $port = 3306;//default
     137        if(stripos($arr_cfg['db.host'],':')){
     138            $port = substr($arr_cfg['db.host'], stripos($arr_cfg['db.host'],':')+1);
     139            $arr_cfg['db.host'] = substr($arr_cfg['db.host'], 0, stripos($arr_cfg['db.host'],':'));
     140        }
     141        $link = mysqli_connect($arr_cfg['db.host'], $arr_cfg['db.user'], $arr_cfg['db.pw'], $arr_cfg['db.name'], $port);
     142    }
    131143    $arr_return['benchmark']['mysql_connect'] = timer_diff($time_start);
    132144
  • wpperformancetester/trunk/readme.txt

    r1949947 r1991341  
    33Tags: performance, admin, benchmark
    44Requires at least: 3.5
    5 Tested up to: 4.9.8
    6 Stable tag: 1.0.1
     5Tested up to: 5.0
     6Stable tag: 1.1
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
    99
    10 WPPerformanceTester benchmarks your server\'s performance through a variety of PHP, MySql and WordPress tests
     10WPPerformanceTester benchmarks your server's performance through a variety of PHP, MySql and WordPress tests
    1111
    1212== Description ==
    13 WPPerformanceTester was written as a tool to benchmark WordPress in the [WordPress Hosting Performance Benchmarks (2015)](http://reviewsignal.com/blog/2015/07/28/wordpress-hosting-performance-benchmarks-2015/) by [Review Signal](http://reviewsignal.com). It was designed to test the server\'s performance by stressing PHP, MySql and running $wpdb queries.
     13WPPerformanceTester was written as a tool to benchmark WordPress in the [WordPress Hosting Performance Benchmarks (2015)](http://reviewsignal.com/blog/2015/07/28/wordpress-hosting-performance-benchmarks-2015/) by [Review Signal](http://reviewsignal.com). It was designed to test the server's performance by stressing PHP, MySql and running $wpdb queries.
    1414
    1515WPPerformanceTester performs the following tests
     
    2222- \\$wpdb - 250 insert, select, update and delete operations through \\$wpdb
    2323
    24 It also allows you to see how your server\'s performance stacks up against our industry benchmark. Our industry benchmark is the average of all submitted test results.
     24It also allows you to see how your server's performance stacks up against our industry benchmark. Our industry benchmark is the average of all submitted test results.
    2525
    2626== Installation ==
     
    3030
    3131== Changelog ==
     32= 1.1 =
     33
     34Added support for hyperdb and socket connections.
     35
    3236= 1.0.1 =
    3337
Note: See TracChangeset for help on using the changeset viewer.