Plugin Directory

Changeset 2083563


Ignore:
Timestamp:
05/08/2019 12:38:16 PM (7 years ago)
Author:
wsec1
Message:

0.5 Change to bechmark formula to cater for Innodb vs MyIsam

Location:
super-host-speed-benchmark/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • super-host-speed-benchmark/trunk/readme.txt

    r2077511 r2083563  
    11=== Super Host Speed Benchmark ===
    22Contributors: wsec1
    3 Tags: Speed,benchmark,performance
     3Tags: Speed,benchmark,performance,speed benchmark
    44Requires PHP: 5.2.4
    55Requires at least: 4.6
     
    45450.4 Added caching machanism for score using wpcron
    4646
     470.5 Change to bechmark formula to cater for Innodb vs MyIsam
     48
  • super-host-speed-benchmark/trunk/shsb.php

    r2077511 r2083563  
    44* Plugin URI: https://superhostspeed.com/
    55* Description: Test and benchmark the speed of your hosting provider, based on the speed of their mysql database, which tends to be the main cause of Wordpress being slow on some hosts. A score of less than 40 is bad and a score of more than 100 is very good. Scores will be reported to our server in future versions so you can compare speeds with others. See Tools/Speed Benchmark
    6 * Version: 0.4
     6* Version: 0.5
    77* License: GPL2+
    88* Copyright 2019 Anthony Walker
     
    135135
    136136$table_name=$wpdb->prefix ."speedtest202";
    137     $sql="CREATE TABLE $table_name (
    138     task_id INT AUTO_INCREMENT,
    139     title VARCHAR(255) NOT NULL,
    140     start_date DATE,
    141     due_date DATE,
    142     status TINYINT NOT NULL,
    143     priority TINYINT NOT NULL,
    144     description TEXT,
    145     PRIMARY KEY (task_id)  ) $charset_collate;";
     137    $sql="CREATE TABLE `speedtest202` (
     138  `task_id` int(11) NOT NULL AUTO_INCREMENT,
     139  `title` varchar(255) NOT NULL,
     140  `start_date` date DEFAULT NULL,
     141  `due_date` date DEFAULT NULL,
     142  `status` tinyint(4) NOT NULL,
     143  `priority` int(11) NOT NULL,
     144  `description` text,
     145  PRIMARY KEY (`task_id`),
     146  KEY `idx` (`priority`)
     147)  $charset_collate;";
    146148
    147149require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     
    151153$wpdb->get_results("delete from $table_name");
    152154
    153     $score=0;
     155    $ictr=0;
    154156    $t=time();
    155     while (time()-$t<15)
    156     {
    157         $score++;
     157    while (time()-$t<5)
     158    {
     159        $ictr++;
    158160        //echo ".";
    159         $sheet = $wpdb->get_results("insert into $table_name (title,status,priority,description) values ('test',1,1,'description')");
     161        $sheet = $wpdb->get_results("insert into $table_name (title,status,priority,description) values ('test',1,$ictr,'description')");
    160162       
    161163    }
     164    $time_start = microtime(TRUE);
     165    $sheet = $wpdb->get_results("select count(*) from $table_name");
     166    $t=time();
     167    $rctr=0;
     168    while (time()-$t<5)
     169    {
     170         $sheet = $wpdb->get_results("select task_id from $table_name where priority=$rctr");
     171         $rctr++;
     172    }
     173    $time_end = microtime(TRUE);
     174    $tm = $time_end - $time_start;
     175   
    162176    $wpdb->get_results("delete from $table_name");
    163177   
     
    182196*/
    183197   
    184     $score=$score/1000;
     198    //$dscore=$ictr/1000;
     199    //$score=$ictr/500+($tm*20);
     200    $s1=$ictr/1000;
     201    $s2=($rctr/100)*3;
     202    $score=$s1+$s2;
     203    echo "Score: $score  | inserts in 5 seconds:$ictr | reads in 5 seconds: $rctr";
     204    //$score=$tm;
    185205   
    186206    $options = get_option( 'shsb_settings' );
     
    209229   
    210230    $shsb_score_time=get_option( "shsb_score_time",0);
     231    $shsb_score_time=0;
    211232    if ($shsb_score_time==0 || time()-$shsb_score_time>60*60*12)
    212233    {
     
    241262    <canvas width=380 height=200 id="gauge" align="center"></canvas>
    242263    <div id="gauge-txt" align="center"></div>
    243    <div>0-100 Slow  ; 100-200 OK ; 200+ Excellent</div>
     264   <div>0-50 Slow  ; 50-70 OK ; 71+ Excellent</div>
    244265 
    245266  </div>
     
    265286  staticLabels: {
    266287  font: "10px sans-serif",  // Specifies font
    267   labels: [50, 100, 150, 200, 300, 400, 500],  // Print labels at these values
     288  labels: [10, 20, 30, 40, 50, 60, 70 ,80 , 90, 100],  // Print labels at these values
    268289  color: "#000000",  // Optional: Label text color
    269290  fractionDigits: 0  // Optional: Numerical precision. 0=round off.
     
    271292
    272293staticZones: [
    273    {strokeStyle: "#FF0000", min: 0, max: 100}, // Red
    274    {strokeStyle: "#0000FF", min: 101, max: 200}, // Blue
    275    {strokeStyle: "#00FF00", min: 201, max: 500} // Green
     294   {strokeStyle: "#FF0000", min: 0, max: 50}, // Red
     295   {strokeStyle: "#0000FF", min: 51, max: 70}, // Blue
     296   {strokeStyle: "#00FF00", min: 71, max: 100} // Green
    276297   
    277298],
     
    280301var target = document.getElementById('gauge'); // your canvas element
    281302var gauge = new Gauge(target).setOptions(opts); // create sexy gauge!
    282 gauge.maxValue = 500; // set max gauge value
     303gauge.maxValue = 100; // set max gauge value
    283304gauge.setMinValue(0);  // Prefer setter over gauge.minValue = 0
    284305gauge.animationSpeed = 32; // set animation speed (32 is default value)
     
    327348function shsb_deactivate()
    328349{
    329 
     350   
    330351wp_clear_scheduled_hook('shsb_cron');
     352delete_option( 'shsb_score' );
     353delete_option( 'shsb_score_time' );
     354
     355}
     356
     357function shsb_uninstal()
     358{
     359     global $wpdb;
     360     
     361     $table_name=$wpdb->prefix ."speedtest202";
     362     $the_removal_query = "DROP TABLE IF EXISTS {$table_name}";
     363     $wpdb->query( $the_removal_query );
    331364
    332365}
     
    337370
    338371register_deactivation_hook( __FILE__, 'shsb_deactivate' );
     372
     373register_uninstall_hook(__FILE__, 'shsb_uninstall');
    339374
    340375
Note: See TracChangeset for help on using the changeset viewer.