Changeset 2083563
- Timestamp:
- 05/08/2019 12:38:16 PM (7 years ago)
- Location:
- super-host-speed-benchmark/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
shsb.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
super-host-speed-benchmark/trunk/readme.txt
r2077511 r2083563 1 1 === Super Host Speed Benchmark === 2 2 Contributors: wsec1 3 Tags: Speed,benchmark,performance 3 Tags: Speed,benchmark,performance,speed benchmark 4 4 Requires PHP: 5.2.4 5 5 Requires at least: 4.6 … … 45 45 0.4 Added caching machanism for score using wpcron 46 46 47 0.5 Change to bechmark formula to cater for Innodb vs MyIsam 48 -
super-host-speed-benchmark/trunk/shsb.php
r2077511 r2083563 4 4 * Plugin URI: https://superhostspeed.com/ 5 5 * 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. 46 * Version: 0.5 7 7 * License: GPL2+ 8 8 * Copyright 2019 Anthony Walker … … 135 135 136 136 $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;"; 146 148 147 149 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); … … 151 153 $wpdb->get_results("delete from $table_name"); 152 154 153 $ score=0;155 $ictr=0; 154 156 $t=time(); 155 while (time()-$t< 15)156 { 157 $ score++;157 while (time()-$t<5) 158 { 159 $ictr++; 158 160 //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')"); 160 162 161 163 } 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 162 176 $wpdb->get_results("delete from $table_name"); 163 177 … … 182 196 */ 183 197 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; 185 205 186 206 $options = get_option( 'shsb_settings' ); … … 209 229 210 230 $shsb_score_time=get_option( "shsb_score_time",0); 231 $shsb_score_time=0; 211 232 if ($shsb_score_time==0 || time()-$shsb_score_time>60*60*12) 212 233 { … … 241 262 <canvas width=380 height=200 id="gauge" align="center"></canvas> 242 263 <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> 244 265 245 266 </div> … … 265 286 staticLabels: { 266 287 font: "10px sans-serif", // Specifies font 267 labels: [ 50, 100, 150, 200, 300, 400, 500], // Print labels at these values288 labels: [10, 20, 30, 40, 50, 60, 70 ,80 , 90, 100], // Print labels at these values 268 289 color: "#000000", // Optional: Label text color 269 290 fractionDigits: 0 // Optional: Numerical precision. 0=round off. … … 271 292 272 293 staticZones: [ 273 {strokeStyle: "#FF0000", min: 0, max: 100}, // Red274 {strokeStyle: "#0000FF", min: 101, max: 200}, // Blue275 {strokeStyle: "#00FF00", min: 201, max: 500} // Green294 {strokeStyle: "#FF0000", min: 0, max: 50}, // Red 295 {strokeStyle: "#0000FF", min: 51, max: 70}, // Blue 296 {strokeStyle: "#00FF00", min: 71, max: 100} // Green 276 297 277 298 ], … … 280 301 var target = document.getElementById('gauge'); // your canvas element 281 302 var gauge = new Gauge(target).setOptions(opts); // create sexy gauge! 282 gauge.maxValue = 500; // set max gauge value303 gauge.maxValue = 100; // set max gauge value 283 304 gauge.setMinValue(0); // Prefer setter over gauge.minValue = 0 284 305 gauge.animationSpeed = 32; // set animation speed (32 is default value) … … 327 348 function shsb_deactivate() 328 349 { 329 350 330 351 wp_clear_scheduled_hook('shsb_cron'); 352 delete_option( 'shsb_score' ); 353 delete_option( 'shsb_score_time' ); 354 355 } 356 357 function 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 ); 331 364 332 365 } … … 337 370 338 371 register_deactivation_hook( __FILE__, 'shsb_deactivate' ); 372 373 register_uninstall_hook(__FILE__, 'shsb_uninstall'); 339 374 340 375
Note: See TracChangeset
for help on using the changeset viewer.