uradvd
Member
Posted 8 months ago #
<?php
//"top-10-counter.js.php" Display number of page views
Header("content-type: application/x-javascript");
<strong>define('SHORTINIT', 'faster');</strong>
if (!function_exists('add_action')) {
$wp_root = '../../..';
if (file_exists($wp_root.'/wp-load.php')) {
require_once($wp_root.'/wp-load.php');
} else {
require_once($wp_root.'/wp-config.php');
}
}
good idea?
http://wordpress.org/extend/plugins/top-10/
[Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]
Am not sure if the code got properly displayed.
The change I see is define('SHORTINIT', 'faster');
Am not sure how this helps?
I believe define('SHORTINIT', true); loads a lighter environment, but I can run some tests to see if it helps speed up the page.
uradvd
Member
Posted 8 months ago #
sorry, yes
define( 'SHORTINIT', TRUE );
minimun load environment. Not load /wp-includes, /wp-content
only $wpdb
Low memory usage(not load full wordpress environment), speed up ajax request
I just tried it in my test blog and its given a decent performance improvement. I'll implement this in the next version.
uradvd
Member
Posted 8 months ago #
uradvd
Member
Posted 8 months ago #
WARNING: [pool www] child 96782, script '/data/site/wp-content/plugins/top-10/top-10-counter.js.php' (request: "GET /wp-content/plugins/top-10/top-10-counter.js.php") executing too slow (1.785353 sec), logging
4k users
30k pageviews/day
Is this the default option?
Did the code above work for you if you edit top-10-counter.js.php ?
It gives a 500 error in my testing.
It did work on the top-10-addcount.js.php
uradvd
Member
Posted 8 months ago #
yes is defaul plugin options
most likely because there is a code which is present in the part which we disable
I thought as much. Let me see what I can do. But, just disabling the addcount which is the main one, saves a good amount of time.
uradvd
Member
Posted 8 months ago #
speedup 500%
I think to create a separate function for each counter as this increases the performance counter display
<?php
//"top-10-counter.js.php" Display number of page views
Header("content-type: application/x-javascript");
define( 'SHORTINIT', TRUE );
if (!function_exists('add_action')) {
$wp_root = '../../..';
if (file_exists($wp_root.'/wp-load.php')) {
require_once($wp_root.'/wp-load.php');
} else {
require_once($wp_root.'/wp-config.php');
}
}
// Display counter using Ajax
function tptn_disp_count_total() {
global $wpdb;
$table_name = $wpdb->prefix . "top_ten";
$count_disp_form = "Views %totalcount%";
$id = intval($_GET['top_ten_id']);
if($id > 0) {
// Total count per post
if (strpos($count_disp_form, "%totalcount%") !== false) {
$resultscount = $wpdb->get_row("SELECT postnumber, cntaccess FROM ".$table_name." WHERE postnumber = ".$id);
$cntaccess = number_format((($resultscount) ? $resultscount->cntaccess : 1));
$count_disp_form = str_replace("%totalcount%", $cntaccess, $count_disp_form);
}
echo 'document.write("'.$count_disp_form.'")';
uradvd, I think this is because the above function isn't fetching the tptn_settings
$tptn_settings = tptn_read_options();
I think this read function makes all the difference, and not because of the %totalcount% option only.
uradvd
Member
Posted 8 months ago #
If you refer to the settings plug if we lose in performance, I think it is better to select the individual components and winning performance
I agree. I think I should be able to modify the code to gain performance.