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)

scotty 03-26-2002 10:39 PM

anyone suggestions for my prob?
https://vborg.vbsupport.ru/showthrea...244#post230244

TECK 03-26-2002 11:06 PM

Quote:

Originally posted by scotty
anyone suggestions for my prob?
https://vborg.vbsupport.ru/showthrea...244#post230244

sessionhash probs. check your hacks.

Jawelin 03-27-2002 08:15 AM

Quote:

Originally posted by nakkid
i'm convinced is a server issue Jawelin. as you see, even in unhacked (details) mode you get negativs. i wish i could do something but i cant. you should contact your host. let me know what they said.. it might help others who have the same prob.
Yes, sure. My server is quite strange (Linux shared...). Even - thanks to your enhanced hack version - I saw they somethimes turn off the gzip for no reason ... Bah!?!?

Instead I often get a negative value on the forumhome page, with about 35 queries. Some hacks installed, but even with the original index.php and templates, the query time has often strange values.
I asked my host people, but they said it's an 'application' issue cause they use a standard MySQL configuration... :rolleyes:

Pragmatically, I would findout a simple way to re-scale strange values with a not-totally-random algorithm... :classic:
I though to 'sql time % 100', but it's too empiric.... :p
Do you have any better idea ?

Thanks and welcome back. As you can see, Nakkid, your work became very popular... :squareeyed:

Bye

lowlight 03-27-2002 11:32 AM

So what's a good stat to have?

Most of my pages are like this:

Page generated in 0.5019860 seconds (91.89% PHP - 8.11% MySQL) with 22 queries.

I guess it's good that MySQL isn't bogging down right? :)

TECK 03-27-2002 11:58 AM

looks good to me.. your stats are solid. not to many queries (very important for your server - keep it under 40)

TECK 03-27-2002 12:02 PM

Quote:

Originally posted by Jawelin
Pragmatically, I would findout a simple way to re-scale strange values with a not-totally-random algorithm... :classic:
I though to 'sql time % 100', but it's too empiric.... :p
Do you have any better idea ?

install a test board with no hacks. this way you will see exacly where is the bug related to your server.

the way your host twisted the answer made me laugh. application prob? hmmm well, with a plain board installed there is nothing thay can commnet on it. i guarantee you will get the same probs. let me know please how it went. :)

lowlight 03-27-2002 12:47 PM

Quote:

Originally posted by nakkid
looks good to me.. your stats are solid. not to many queries (very important for your server - keep it under 40)
Yeah I want to keep everything running nicely... I have PHP-Accelerator installed, and MOD_GZIP... I hope all that helps, because I am going to make my site into a full dynamically-served site!

Wish me luck :D

JDD 03-27-2002 01:20 PM

Hi...

I have examined the code a little bit deeper, and I got a solution for these negative value problems, I think.
In my opinion it is a little bug in your hack. I figured out that my pagestarttime was always set to zero.
This is caused in global.php:
PHP Code:

if (isset($explain)) {
  
$showqueries=1;
}
if (isset(
$showqueries)) {
  
$pagestarttime=microtime();


so it will only be set if showqueries is set.

I changed it to:

PHP Code:

$pagestarttime=microtime();

if (isset(
$explain)) {
  
$showqueries=1;
}
if (isset(
$showqueries)) {
  
$pagestarttime=microtime();


so.. with this I got a start time. But there is an other little problem in functions.php.

replace this:

PHP Code:

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

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

with
PHP Code:

// 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"

and now it should work perfectly, at least for me it does :)

Greets
JDD

If this may be wrong, just inform me and I edit this (but I think it should solve the problem)

TECK 03-27-2002 10:59 PM

PHP Code:

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

initially, that's what i had in my hack, but the numbers were most of the time messed.. that was the issue i debated with firefly. he did the same thing here at vB.org. i cannot explain it why but this will work only in 20% of servers. as you see, there are alot of users who dont have this problem at all.. so i decided to leave it the way it is. firefly even went deeper then you think, by contacting a develloper at vB.com just to get an answer to the mistery.

leave the rest unchanged, it should work fine, the starttime must be set to zero.

JDD 03-28-2002 06:43 AM

Quote:

initially, that's what i had in my hack, but the numbers were most of the time messed..
jepp, no wonder if starttime is allways set to zero. You would get funny looking huge values most of the time ;) (exactly the difference to 1.1.1970 :D) btw. how do you calculate times over 1 sec with not handling the seconds part of microtime at all in your totaltime?

Quote:

leave the rest unchanged, it should work fine, the starttime must be set to zero.
sorry to disagree here as well... But if starttime is set to zero you will never get correct values.. The reason why the mysql part works is easy. You don't subtract the endtime from the starttime directly but go over some interims vars (beforetime, aftertime), so the starttime part isn't invovled in the calculating at all.

So, just give my modifications a chance and try them out, you'll see they would work. I have no clue why it is working on vB.org, but I doubt they use your code in it's original form.
This is btw. a really nice hack - I like it very much therefore I tried to make it work and excamined it a little bit more than usual.

JDD

Jawelin 03-28-2002 08:03 AM

Extension: how could I use a similar replacement variable (or at least similar calculation) to show stats of some AdminCP pages ?

Note: db_mysql.php vars are of course always present (saw appending &explain=1 to the query_string) ....

I tried to call dooutput(" ", 0) just before the end of AdminCP page and then use $microstats variable (correctly set), but got an unexpected behavior of that function...
I saw unprintable chars .... for example.

Thnx

Jawelin 03-28-2002 08:25 AM

Quote:

Originally posted by JDD
$totaltime=$endtime[0]-$starttime[0]+$endtime[1]-$starttime[1];
I noticed a possible incongruence (or simply an algorithm I can't understand... :ogre:) between the original - corrected by FF - time calculation of functions.php and the same calc within db_mysql.php, where both are made with:
PHP Code:

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

:eek:
Thnx

JDD 03-28-2002 11:26 AM

Hi...

Quote:

I noticed a possible incongruence (or simply an algorithm I can't understand... ) between the original - corrected by FF - time calculation of functions.php and the same calc within db_mysql.php, where both are made with
yes there is possible an incongruence, if global.php is called more than once to generate a page, the starttime var would be set to a different value (if global.php is only called once the startime would be of the same value during the whole calculation)
For the endtime var it doesn't matter because it is always set to the current time just before it is used. So only starttime could be a prob, I have a solution for it to fix.. just sent me a pm so we could try it out (unfortunately I couldn't test it, because the ftp server of my webpage is currently down, therefore I don't post it because I am not sure that it does work 100%)

JDD

Jawelin 03-28-2002 12:28 PM

Quote:

Originally posted by nakkid
install a test board with no hacks. this way you will see exacly where is the bug related to your server.
Actually I don't think it depends on installed hacks...

Let me try. Looking at php.net manual for microtime() I tried to use that sample function
PHP Code:

function getmicrotime(){ 
    list(
$usec$sec) = explode(" ",microtime()); 
    return ((float)
$usec + (float)$sec); 


to measure my sample page (with many sql queries) loading time.
Well.
I got values of about 3-4 seconds, nearest to the actual latency time before displaying on a fast connection... many more than 0.7 seconds displayed by { getmicrostats } function at the end of the same page...

:ermm:

Heeeellllllllpppppppp !!!!!!!! :squareeyed:

TECK 03-28-2002 04:54 PM

Quote:

Originally posted by JDD
You would get funny looking huge values most of the time ;) (exactly the difference to 1.1.1970)
that's what i got. then i shortenned the code and it worked ok.

Quote:

Originally posted by JDD
So, just give my modifications a chance and try them out, you'll see they would work. I have no clue why it is working on vB.org, but I doubt they use your code in it's original form.
FireFly uses the code i posted, except that it has the full start-endtime line the way it was defaulted (not mines). it doesnt have the starttime mod in global.php. i will set it as you mention tonite at home and if ok, i will add it to the hack.. ;)

also, what time values you get when you load the page? can you post a website so i see the way it works on your server?

TECK 03-28-2002 04:59 PM

Quote:

Originally posted by Jawelin
I noticed a possible incongruence (or simply an algorithm I can't understand... :ogre:) between the original - [high]corrected by FF[/high] - ...
just to clear things up Jawelin. this hack was verified by FireFly, not edited. all hack is written by me, except the PHP-MySQL% addon (made by FireFly, with proper credit in the .txt file). he also explained to me what is the proper way to call the {microstats} variable anywhere.

Jawelin 03-28-2002 08:28 PM

Quote:

Originally posted by nakkid
just to clear things up Jawelin. this hack was verified by FireFly, not edited. all hack is written by me
[...]

Thanks for having pointed it out, np, but I just was talking about the algorithm... and I was talking to you, of course.
Referred to FF only to identify the original hack and distinguish it from the variant by JDD. That's all.

Btw, as I repeat, the 'empirical' way following the php.net gave numbers about 5-7 times larger than microstats values...
That's my question.
;)
Thnx

TECK 03-28-2002 11:26 PM

This upgrade will fix the negative values some users get when loading a page.

CREDITS:
JDD
pagestarttime addon in [high]global.php[/high]

VB2.2.4 forum/global.php (2 changes)
1. Find the code:
PHP Code:

if (isset($showqueries)) {
  
$pagestarttime=microtime();


Replace it with:
PHP Code:

$pagestarttime=microtime(); 

2. Find the code:
PHP Code:

$templatesused.=',pagenav,pagenav_curpage,pagenav_firstlink,pagenav_lastlink,pagenav_nextlink,pagenav_pagelink,pagenav_prevlink'

Replace it with:
PHP Code:

$templatesused.=',pagenav,pagenav_curpage,pagenav_firstlink,pagenav_lastlink,pagenav_nextlink,pagenav_pagelink,pagenav_prevlink,home_microstats'

forum/admin/functions.php (1 change)
1. Find the code:
PHP Code:

$totaltime=$endtime[0]-$starttime[0]; 

Replace it with:
PHP Code:

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


wooolF[RM] 03-29-2002 01:08 AM

]works great :) thanx :)

David Bott 03-29-2002 01:12 AM

At this point I can say I have not seen a negitive number with the fix above. Thank you.

TECK 03-29-2002 01:16 AM

i modified a little the [high]$pagestarttime[/high] code JDD posted initially.
let's hope that will cure all the probs...... ;)

Kyomu 03-29-2002 02:47 AM

Quote:

Originally posted by nakkid
This upgrade will fix the negative values some users get when loading a page.

CREDITS:
JDD
pagestarttime addon in [high]global.php[/high]

forum/global.php (2 changes)
1. Find the code:
PHP Code:

if (isset($showqueries)) {
  
$pagestarttime=microtime();


Replace it with:
PHP Code:

if (isset($showqueries)) {
  
$pagestarttime=microtime();
} else {
  
$pagestarttime=microtime();



Can't that just be replaced with
PHP Code:

$pagestarttime=microtime(); 

Either case of the if statement will yield that code... so there really is no need for the if statement. Right?

TECK 03-29-2002 02:50 AM

$showqueries is present and it asks for microtime.. the rest is for my hack.. :)
i did it this way so you dont get any wierd errors if u miss [high]isset[/high]. i like to leave VB unchanged in those areas.. you never know where it can hit you with an error. leave it this way, it will not hurt nothing.

FWC 03-29-2002 06:01 AM

Quote:

Originally posted by nakkid
This upgrade will fix the negative values some users get when loading a page.
That did the trick! Thank you. :classic:

Admin 03-29-2002 06:33 AM

Quote:

Originally posted by nakkid
$showqueries is present and it asks for microtime.. the rest is for my hack.. :)
i did it this way so you dont get any wierd errors if u miss [high]isset[/high]. i like to leave VB unchanged in those areas.. you never know where it can hit you with an error. leave it this way, it will not hurt nothing.

He's right though, it really doesn't matter. It's like:
Code:

if ($me == $you) {
  echo 'yea';
} else {
  echo 'yea';
}

No matter what it will echo yea, so you better just remove the if statement.

Renegade 03-29-2002 09:39 AM

Very cool hack, especially when debugging the board.

TECK 03-29-2002 01:33 PM

Quote:

Originally posted by FireFly
He's right though, it really doesn't matter.
done, removed the code. wasnt sure if it would not affect anything.. ;)

TECK 03-30-2002 02:40 AM

in other order of ideas... can you post if there are still any negative values present at all time?
thanks.

Jawelin 03-30-2002 07:51 AM

Quote:

Originally posted by nakkid
in other order of ideas... can you post if there are still any negative values present at all time?
thanks.

Nakkid, here I'm.
Since installed 1.7 I never got negative values any more, even on the forumhome... :knockedout:

Still I'm receiveing strange values for time. As JDD said before perhaps due to global.php reloaded many times (so even the pagestarttime many times reset), I always get too small values for microseconds elapsed. :(

I made this check:
  • created a function getmicrotime() to expand seconds and microseconds, as sampled on php.net
  • put a $customstartpage=getmicrotime() at the top of a php page
  • put a $customstoptime = getmicrotime() at the end of an action
  • displayed the difference near the { getmicrostats } replacement variable
  • ...
Well. $customdifference values are MUCH larger than the {gms} variable one !!! (about an order... i.e. 10 vs. 1 !!! )

How could I force the pagestarttime reset only at the very beginning of the page and not other times within ????

Thanks again for all your upgrades and support .
Bye

TECK 03-30-2002 11:12 AM

hmm.. did you tried the simple plain microtime? instead of exploding it like at php.net?

Jawelin 03-30-2002 11:28 AM

Quote:

Originally posted by nakkid
hmm.. did you tried the simple plain microtime? instead of exploding it like at php.net?
No... See Post #174 above...

I put that getmicrotime() function in functions.php and used it both times, for start and stop time.
Even used strange var names to be sure they weren't messing anything.
And got a final global difference of about 4-6 seconds... The same page, at the end, I see the {gms} var about 0.56xxxxx seconds.

That's very strange...
:confused:

Thanks

TECK 03-30-2002 06:35 PM

strange indeed. so you get those values only with the microtime from php.net? as a .php file? or part of vBulletin?

Viruseater 03-31-2002 01:35 AM

I read this thread. Well I skipped through it, looking for an error like I'm getting. Didn't see one so I'm posting about it.

I've installed this hack on my webserver. it's pulling some strange information.

here's the results of the query.

Page generated in 1,017,549,010.701014 seconds (100.00% PHP - 0.00% MySQL) with 21 queries.

Don't think I need to define much, pretty self explanitory.

I'm converting a few UBB's over to vBulletin since I just bought it. (bring 5 UBB's down, and combining them into one VB.

I've hacked the crud out of the UBB's but most of what I want in the boards are already here in VB.

I'm sure it's a newbie thing. Just don't know where to go. I've completed the import of my threads and users, but just cannot figure this out, and want to resolve it before i go to production. You can see the test bed here:

www.clanservers.net/forumtest

If this has already been addressed, I apologize, and if someone could link me to where it's resolved I'd be very greatful.

V

Viruseater 03-31-2002 01:38 AM

and before anyone says how ugly the individual categories are inside, heehe I know, but I don't care about looks on this board, just functionality. So I'll correct the themes when I get everything working.

TECK 03-31-2002 03:05 AM

Quote:

Originally posted by Viruseater
Page generated in 1,017,549,010.701014 seconds (100.00% PHP - 0.00% MySQL) with 21 queries.
you forgot to edit properly your global.php
check the file.

FWC 03-31-2002 03:26 AM

Quote:

Originally posted by Viruseater
here's the results of the query.

Page generated in 1,017,549,010.701014 seconds (100.00% PHP - 0.00% MySQL) with 21 queries.

You hacked the wrong file. You will get that result if you modify admin/global.php instead of the global.php in the forums root. I know, I found out the hard way. :)

Viruseater 03-31-2002 03:46 AM

That sounds like exactly what I likely did.

Doesn't make sense to me that there'd be duplicate file names like that, but I'm no coder, so I'll keep my mouth shut prior to making a fool of myself.

I found another error, so I wiped the entire board, and am setting it up again, so I'll hack the right file now :p

thanks for the replies!

TECK 03-31-2002 04:06 AM

Viruseater, check your code. you get those values only because vB is looking for [high]$pagestarttime[/high] and it can't find it.
if you check all the steps carefully, you will see your mistake.

regards,
nakkid.

Jawelin 03-31-2002 12:09 PM

Quote:

Originally posted by nakkid
strange indeed. so you get those values only with the microtime from php.net? as a .php file? or part of vBulletin?
Nakkid, yes, I used VBulletin files, double checked your v1.7 hack
statements against my modified files. Last, as said, I put the
getmicrotime() function in admin/functions.php exactly
as it's described on www.php.net

This is exactly what I did: I used two files index.php, called
index224_plain.php and index224_hackd.php and uploaded to
forum home dir, respectively the original 2.2.4 version and the
hacked one.

Both with some mods:
PHP Code:

// just after
require('./global.php');
// put
$custompagebeginmicrotime = (float)getmicrotime();


// Then, in 4-5 different points of the two files (same points), i put these two rows:
$bulkloadmicrotime number_format(getmicrotime()-$custompagebeginmicrotime,7);
echo 
"<font size=1 face='arial'>Bulk load microtime [qrs=$query_count] (xxxx breakpoint identification) = <b>$bulkloadmicrotime</b></font><br>"

Besides, in global.php with an
PHP Code:

echo "<h1>Pagestarttime Global reset</h1>" 

just after the $pagestarttime=microtime() at the beginning
of the page, I ensured that script is called only ONCE by index.php...

Note: last two days, for some unexplained reason, my server
disabled GZip and any other encoding ... I hope it's a short time event... :(

Code:

PLAIN index.php
---------------
Bulk load microtime [qrs=6] (start time)                                        = 0.0000969
Bulk load microtime [qrs=13] (after processing main SELECT group)              = 0.0069339
Bulk load microtime [qrs=19] (after processing most SELECTs and some templates) = 0.0228729
Bulk load microtime [qrs=19] (before processing main template)                  = 0.0863299
{ getmicrostats }=  Page (81.17% PHP + 18.83% MySQL) with 19 queries generated in 0.1926436
Bulk load microtime [qrs=20] (after processing all templates)                  = 0.7915579


HACKED index.php
----------------
Bulk load microtime [qrs=6]  (start time)                                      = 0.0000930
Bulk load microtime [qrs=26] (after processing main SELECT group)              = 0.5236299
Bulk load microtime [qrs=33] (after processing most SELECTs and some templates) = 0.5396340
Bulk load microtime [qrs=38] (before processing main template)                  = 0.6587319
{ getmicrostats }=  Page (20.74% PHP + 79.26% MySQL) with 38 queries generated in 0.7506131
Bulk load microtime [qrs=39] (after processing all templates)                  = 2.1796360

As you can see, the results pointed out most of the page time is
taken by the forumhome template processing. Much more than all
the SELECTs (38 with hacks, 19 with the plain version). And the
{ getmicrostats } is evalued BEFORE the
template is loaded and processed. Infact that value is almost
similar to mine as computed immediately before the eval
("forumhome template").

Of course, the doubled number of queries in the hacked version
reversed also the percentage ratio of php vs. sql ...

Interesting, isn't it ? :)

Hope I was able to explain myself
:stupid:

Thanks.

TECK 03-31-2002 09:59 PM

i dont know what to say Jawelin. anyone else have the same problem? so far everyone is really happy with 1.7...


All times are GMT. The time now is 05:00 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.01848 seconds
  • Memory Usage 1,907KB
  • 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
  • (2)bbcode_code_printable
  • (18)bbcode_php_printable
  • (22)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