vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   vbMicroStats: page load time, queries, GZIP and PHP version (https://vborg.vbsupport.ru/showthread.php?t=35811)

TECK 04-28-2002 03:51 PM

ok.. i added the code above.

b-b00gie 04-30-2002 04:37 AM

This hack is giving me so much trouble installing it... :-\


i'm getting the following error:

Code:

Parse error: parse error in /home2/public_html/forum/admin/functions.php on line 496

Fatal error: Call to undefined function: iif() in /home2/public_html/forum/admin/functions.php on line 351


I've gone over the install 20+ times. I verified that I made the correct changes and to the correct files.


If I undo the changes to functions.php (copy the text to replace from the install file) everything goes back to normal. When I replace the text I get the error again. :depressed:


I'm using 2.2.5 btw.

b-b00gie 04-30-2002 04:49 AM

additionally...


this is my line 351 in functions.php

PHP Code:

$usercache["$userid"]['showvbcode'] = iif(($usercache["$userid"]['options'])&SHOWVBCODE,1,0); 




this is my line 496 in functions.php

PHP Code:

// ###################### Start dooutput #######################
function dooutput($vartext,$sendheader=1) {

  global 
$pagestarttime,$query_count,$showqueries,$querytime,$DB_site,$gzipoutput,$gziplevel,$bbuserinfo,$debug,$microstats;

  
$pageendtime=microtime();

  
$starttime=explode(" ",$pagestarttime);
  
$endtime=explode(" ",$pageendtime);

  
// time format (how many digits you want to show)
  
$digits=7;

  
$totaltime=$endtime[0]-$starttime[0]+$endtime[1]-$starttime[1];
  
$trimmedtime=number_format($totaltime,$digits);
  
$percentphp=number_format(((($totaltime-$querytime)/$totaltime)*100), 2)."% PHP";
  
$percentsql=number_format((($querytime/$totaltime)*100), 2)."% MySQL";

  if (
$bbuserinfo['usergroupid']==6) {
    if (
$gzipoutput==1) {
      
$gziptext="GZIP library compression enabled (level $gziplevel)";
    } else {
      
$gziptext="GZIP library compression disabled";
    }
    if (
$debug==1) {
      
$debugmode="(Debug mode)";
    } else {
      
$debugmode="";
    
$versionphp=phpversion();
    
$adminstats="PHP version $versionphp $debugmode with $gziptext. [<a href=\"$PHP_SELF?explain=1\" target=\"_blank\">details</a>]";
  } else {
    
$adminstats="";
  }

  if (
$showqueries) {
    
$vartext .= "<!-- Page generated in $totaltime seconds with $query_count queries -->";
  } else {
    
$microstats "Page generated in $trimmedtime seconds ($percentphp - $percentsql) with $query_count queries.<br> 
                   
$adminstats";
  } 


Line 494: } else {
Line 495: $adminstats="";
Line 496: }

TECK 04-30-2002 05:21 AM

remove $debug from the global.
then remove:
Code:

    if ($debug==1) {
      $debugmode="(Debug mode)";
    } else {
      $debugmode="";

also remove $debugmode variable from $adminstats line... is useless information. i will mod the hack right now. this debug thing gave me only problems.

b-b00gie 04-30-2002 06:42 PM

Quote:

Originally posted by nakkid
remove $debug from the global.
then remove:
Code:

    if ($debug==1) {
      $debugmode="(Debug mode)";
    } else {
      $debugmode="";

also remove $debugmode variable from $adminstats line... is useless information. i will mod the hack right now. this debug thing gave me only problems.


That did it! No more error. :classic: It works great now.

TECK 04-30-2002 07:49 PM

i'm glad. congrats... and sorry, it was my mistake that code. it will work only if you have $debug enabled in config.php

b-b00gie 04-30-2002 08:38 PM

Just a question... is there a way to limit the decimal places of the load time?

For example, I get something like: Page generated in .2973462 seconds...

Can I limit it to 2 or 3 decimal places somehow? not sure :\

TECK 04-30-2002 09:14 PM

Code:

// time format (how many digits you want to show)
$digits=7;

change it to what value you want. if you want to show the last 4 digits, it should be $digits=4;
so it will look like: Page generated in 0.2973 seconds...

b-b00gie 04-30-2002 10:48 PM

Silly mistake! I didnt see the variable... Thanks again for all your help.
;)

TECK 05-01-2002 02:09 AM

firefly, i noticed something related to your code addon for this hack. in your site, the PHP % is always smaller then the MySQL %.
the normal way is: your PHP value should always be bigger then the MySQL one (like it's supposed to be in EXPLAIN=1). everyone's page does that, except here at vB.org. just letting you know. if i'm wrong, correct me please.

b-b00gie 05-01-2002 02:29 AM

Quote:

Originally posted by nakkid
firefly, i noticed something related to your code addon for this hack. in your site, the PHP % is always smaller then the MySQL %.
the normal way is: your PHP value should always be bigger then the MySQL one (like it's supposed to be in EXPLAIN=1). everyone's page does that, except here at vB.org. just letting you know. if i'm wrong, correct me please.


Mine does the same thing. Take a look for yourself http://www.g20.net/forum reload as much as you wish.


My average is about .30 seconds to generate the page and 35% PHP and 65% SQL.


I think it may be because I have a dedicated mySQL server, its not on the localhost. :squareeyed:

b-b00gie 05-01-2002 02:37 AM

Also, I looked at my $adminstats and on average I see something like...

Page generated in 0.26241195201874 seconds with 22 queries,
spending 0.18734097480774 doing MySQL queries and 0.075070977210999 doing PHP things.

The SQL is taking longer to generate than PHP. Again, most likely because my VB is connecting to a db on a seperate machine. Although it is still rather fast. :classic:

TECK 05-01-2002 02:50 AM

probably that's the case... :)
thanks for the info. i was just curious.
however, if i do this here, at vB.org (the EXPLAIN=1) it's telling me the viceversa, what is listed in %, at the bottom of the page.

Thomas P 05-04-2002 12:44 PM

New db_mysql.php released:
http://www.vbulletin.com/forum/showt...threadid=45395

TECK 05-04-2002 06:21 PM

i will change the file when VB226 will be oficially released. (today)

JoshFink 05-04-2002 07:55 PM

I like this hack. Just out of curiousity, what is an "Ideal" number to get for PHP and MySql and how do they relate?

Boy was that vague.. :D

Thanks for the help,

Josh

TECK 05-04-2002 07:57 PM

it depends on your server. there are no ideal numbers. hope that helps.

regards,
nakkid.

Jawelin 05-04-2002 09:19 PM

Quote:

Originally posted by nakkid
it depends on your server. there are no ideal numbers. hope that helps.

Sorry, Nakkid. Many posts before, you talked about the number 40 as the maximum acceptable for queries on forumhome... (apart of VBPortal... w/ more than hundred...)

I have many hacks installed involving the first page, and now I'm round 43-45... And i'm working to something else... more! :cheeky:

Btw I still have numbers like:
Code:

Page generated in 0.65888 seconds
(34.21% PHP v4.1.2 + 65.79% MySQL v3.23.45)
with 43 queries. GZip level 1. [details]

wich seem acceptable to me...

Actually, is there any reason for the limit under 40 ? Shall I be afraid of arriving till 50 ? :confused:
Thanks a lot.
Bye

TECK 05-04-2002 10:00 PM

i probably understood wrong the question. i thought he was referring at the %. :)
well, if i understood corectly from firefly, the more queries you have, the higher your server load will be. eventually, on a busy board it will bring the server to it's knees and your host will cancel your account. there are alot of people out there who have 150queries on a page, without even knowing.

so i set myself a goal not to have more then 40queries on a page. even 40, on a very busy board, is dangerously high. i'm talking about boards with 300-400 users online that activly post every second. if you have 50queries, that will kill your server, if not even crashing it.

the highest value will be arround 34queries, on my site. and that's the main page (vbHome full version).

Thomas P 05-04-2002 10:00 PM

Quote:

Originally posted by nakkid
i will change the file when VB226 will be oficially released. (today)
Thanks :)
-Tom

pipsy 05-05-2002 01:38 AM

nothing happens when i put {getmicrostats} in my footer template :( all i see it '' {getmicrostats} '' on my page :(
i'm obviously doing something wrong. and i have no idea what.

pipsily yours.

TECK 05-05-2002 02:38 AM

i'm sorry but i can't do nothing about it. please check you code. there are alot of changes so one little mistake can ruin it all. good luck.

FWC 05-05-2002 04:39 AM

Quote:

Originally posted by nakkid
i will change the file when VB226 will be oficially released. (today)
I modified and applied the hack to the new db_mysql.php that was released and it's working fine. :)

TECK 05-05-2002 04:47 AM

thanks.. :)
however the details link will not work anymore in 226. is ok, i will add the code separately. i will need the ok from some of the gurus here, to make sure the code is secure. as soon as 226 is released i will look into it.

until then, FWC, can you post more details about the change? i didnt have a chance to look into it. thanks.

FWC 05-05-2002 05:01 AM

I used Beyond Compare to compare my old hacked file and the new one. I just copied over the parts I thought were necessary for your hack to work. Explain and showqueries are gone now so I left all of that stuff out. I'll take a look at it and post what I added.

FWC 05-05-2002 05:14 AM

OK, it looks like I changed this:
PHP Code:

  function query($query_string) {
    global 
$query_count;
    
// do query

    
$this->query_id mysql_query($query_string,$this->link_id);
    if (!
$this->query_id) {
      
$this->halt("Invalid SQL: ".$query_string);
    }

    
$query_count++; 

To this:
PHP Code:

  function query($query_string) {
    global 
$query_count,$querytime;
    
// do query

      
global $pagestarttime;
      
$pageendtime=microtime();
      
$starttime=explode(" ",$pagestarttime);
      
$endtime=explode(" ",$pageendtime);

      
$beforetime=$endtime[0]-$starttime[0]+$endtime[1]-$starttime[1];

    
$this->query_id mysql_query($query_string,$this->link_id);
    if (!
$this->query_id) {
      
$this->halt("Invalid SQL: ".$query_string);
    }

    
$query_count++;
      
$pageendtime=microtime();
      
$starttime=explode(" ",$pagestarttime);
      
$endtime=explode(" ",$pageendtime);

      
$aftertime=$endtime[0]-$starttime[0]+$endtime[1]-$starttime[1];
      
$querytime+=$aftertime-$beforetime

Now that I'm looking at it again, I don't think $showqueries and $explain are necessary in the global statement anymore.

TECK 05-05-2002 05:20 AM

they are unset? i didnt downloaded the new file. i wanted to wait for the 226 release. busy working on my website...

FWC 05-05-2002 05:32 AM

Yes, they are unset. I just took them out and everything seems to work fine.

TECK 05-05-2002 05:34 AM

can you edit the code above and remove them from global?
thanks.

NTLDR 05-05-2002 06:18 PM

The update in Post 306 (above) also worked fine for me with the updated 2.2.6 db_mysql.php on vB 2.2.4

Thanks for the update ;)

FWC 05-05-2002 06:29 PM

Quote:

Originally posted by NTLDR
The update in Post 306 (above) also worked fine for me with the updated 2.2.6 db_mysql.php on vB 2.2.4

Thanks for the update ;)

I'm glad it's working for two of us. Beyond Compare came to the rescue. :)

freakyshiat 05-05-2002 08:14 PM

The update in 306 is working for me also

KuraFire 05-06-2002 08:50 AM

The update for the new db_mysql is working for me, too.

However, the hack itself wasn't properly working before that, nor is it now. My percentages are completely odd:

Page generated in 0.4714550 seconds (163.74% PHP / -63.74% MySQL) with 20 queries

Page generated in 1.6309210 seconds (-6.54% PHP / 106.54% MySQL) with 20 queries

Page generated in -0.6399480 seconds (36.72% PHP / 63.28% MySQL) with 20 queries
(percentages good, generation time negative... wow)

I even had 5K~ and -5K~ percentages, a few times.

WHAT AM I DOING WRONG?! :'(

I am using php version 4.0.4pl1 on my own computer, might this be the cause of the problem?

TECK 05-06-2002 05:39 PM

hmm kurafire. wierd, it looks like a previous version bug.. this is how i updated the new db_mysql.php:

find:
Code:

  function query($query_string) {
    global $query_count;
    // do query

    $this->query_id = mysql_query($query_string,$this->link_id);
    if (!$this->query_id) {
      $this->halt("Invalid SQL: ".$query_string);
    }

    $query_count++;

    return $this->query_id;
  }

replace it with:
Code:

  function query($query_string) {
    global $query_count,$querytime,$pagestarttime;
    // do query

    $pageendtime=microtime();
    $starttime=explode(" ",$pagestarttime);
    $endtime=explode(" ",$pageendtime);

    $beforetime=$endtime[0]-$starttime[0]+$endtime[1]-$starttime[1];

    $this->query_id = mysql_query($query_string,$this->link_id);
    if (!$this->query_id) {
      $this->halt("Invalid SQL: ".$query_string);
    }

    $query_count++;

    $pageendtime=microtime();
    $starttime=explode(" ",$pagestarttime);
    $endtime=explode(" ",$pageendtime);

    $aftertime=$endtime[0]-$starttime[0]+$endtime[1]-$starttime[1];
    $querytime+=$aftertime-$beforetime;

    return $this->query_id;
  }

and it's working perfectly. make sure you download the latest version and follow the steps in there, you probably have 1.6 installed. also get the latest php binaries. let me know please.

KuraFire 05-06-2002 07:52 PM

I used your new code there, but it's still giving me freakish results.

I *did* 'adopt' a small change by FireFly because without it, my forum looked like a weird rainbow-thing. He said it was something to do with my low PHP version (4.0.4pl1) - might it be that this also caused the mess-up, or is it more logical that my php-version is the problem?

I tried installing new binaries of PHP but for some strange reason, the version never changed. I uninstalled and re-installed like 4 times, didn't work. :(

TECK 05-06-2002 07:56 PM

i know what is it!! upgrade your php binaries!! it hapened the same thing to another user who used PHP4.01. also make sure that your file says: vbMicroStats version 1.7
if it doesnt, delete all your temp files and download it again. let me know how it goes.

GOD-Dblade 05-07-2002 12:21 AM

hm...anything working with the new update?

TECK 05-07-2002 02:01 AM

what do you mean anything working with the new update?
i do not understand. if you refer to the new db_mysql.php file, read above few posts...

ok, i placed a link on the first post.. so is easy for everyone to get the new db_mysql.php file and the hack update.

KuraFire 05-07-2002 08:02 AM

nakkid: I'll try, though I think I have to uninstall apache, mysql & php all at once, before it'll work. Like I said, for some weird reason, upgrading didn't do jack sh** the past 4 times :(

*makes note to do this in the afternoon*

thx :)

tkeil69575 05-07-2002 08:08 AM

Hallo Nakkid,
me again. Well I found out that my provider is not using the latest php. Hes still got php 4.0.4pl. So I guess thats my problem.

Ive asked him to install a newer version and he sais he will do soon but would like to know why. So sorry, but I have to ask you why. What version do I need and why?

regards Tina


All times are GMT. The time now is 11:12 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01733 seconds
  • Memory Usage 1,871KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (4)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete