PHP Classes

File: test_httperf.html

Recommend this page to a friend!
  Classes of Manuel Lemos  >  Httperf server stressing and benchmark tool  >  test_httperf.html  >  Download  
File: test_httperf.html
Role: ???
Content type: text/plain
Description: Test script to configure the server test options.
Class: Httperf server stressing and benchmark tool
Evaluate HTTP server performance.
Author: By
Last change:
Date: 22 years ago
Size: 7,989 bytes
 

Contents

Class file image Download
<? /* * test_httperf.html * * @(#) $Header: /cvsroot/httperf/test_httperf.html,v 1.7 2000/02/17 23:37:53 mlemos Exp $ * */ Function Output($text) { echo $text; } Function OutputDebug($error) { echo "$error\n"; } Function MakeTests(&$results,&$output) { global $httperf,$url,$hog,$connections,$steps; switch($hog) { case "2": $first=1; if($steps>$connections) $steps=$connections; break; default: $first=$connections; $steps=1; break; } eregi("^http\\://([^:/]*)(\\:[0-9]+)?(/[^#]*)",$url,$split_url); $httperf->server=$split_url[1]; $httperf->port=($split_url[2]=="" ? 80 : intval(substr($split_url[2],1))); $httperf->uri=$split_url[3]; $httperf->hog=($first<$connections); for($step=0;$step<$steps;$step++) { $output=array(); $httperf->connections=intval($first+($steps>1 ? $step*($connections-$first)/($steps-1) : 0)); $test_results=$httperf->RunTest(&$output); if(count($test_results)) { if($first<$connections) $results[$httperf->connections]["duration"]=$test_results["duration"]; } else return($httperf->error); } return(""); } require("httperf.php"); $httperf=new httperf_class; $httperf->httperf_path="/usr/local/bin/httperf"; require("forms.php"); $httperf_form=new form_class; $httperf_form->NAME="httperf_form"; $httperf_form->METHOD="GET"; $httperf_form->ACTION=$PHP_SELF; $httperf_form->Debug="OutputDebug"; $httperf_form->ResubmitConfirmMessage="Are you sure you want to submit this form again?"; $httperf_form->AddInput(array( "TYPE"=>"text", "NAME"=>"url", "VALUE"=>"http://localhost/", "ValidateAsNotEmpty"=>1, "ValidateRegularExpression"=>"^http\\://(([-A-Za-z0-9_]+\\.)+[A-Za-z]{2,4}|localhost)(\\:[0-9]+)?/[^#]*$", "ValidationErrorMessage"=>"It was not specified a valid HTTP url." )); $httperf_form->AddInput(array( "TYPE"=>"text", "NAME"=>"connections", "VALUE"=>1, "ValidateAsInteger"=>1, "ValidationLowerLimit"=>1, "ValidationErrorMessage"=>"It was not specified a valid number of connections." )); $httperf_form->AddInput(array( "TYPE"=>"select", "NAME"=>"hog", "OPTIONS"=>array( "0"=>"Individual", "1"=>"Simultaneous", "2"=>"Simultaneous and incremental" ), "VALUE"=>1, "ValidationErrorMessage"=>"It was not specified a valid test type." )); $httperf_form->AddInput(array( "TYPE"=>"text", "NAME"=>"steps", "VALUE"=>10, "ValidateAsInteger"=>1, "ValidationLowerLimit"=>2, "ValidationErrorMessage"=>"It was not specified a valid number of graphical steps." )); $httperf_form->AddInput(array( "TYPE"=>"text", "NAME"=>"width", "VALUE"=>320, "ValidateAsInteger"=>1, "ValidationLowerLimit"=>80, "ValidationErrorMessage"=>"It was not specified a valid number of graphical steps." )); $httperf_form->AddInput(array( "TYPE"=>"text", "NAME"=>"height", "VALUE"=>200, "ValidateAsInteger"=>1, "ValidationLowerLimit"=>50, "ValidationErrorMessage"=>"It was not specified a valid number of graphical steps." )); $httperf_form->AddInput(array( "TYPE"=>"submit", "VALUE"=>"Test", "NAME"=>"doit" )); $httperf_form->LoadInputValues(IsSet($doit)); $verify=array(); if(IsSet($doit)) { if(($error_message=$httperf_form->Validate(&$verify))=="") { $doit=1; $httperf->width=$width; $httperf->height=$height; } else { $doit=0; $error_message=HtmlEntities($error_message); } } else { $error_message=""; $doit=0; } if(($doit || strcmp($error_message,"")) && IsSet($graphic) && !strcmp($hog,"2")) { if($doit) { if(!strcmp($error=MakeTests(&$results,&$output),"")) { if($httperf->DrawGraph(&$results)) { $httperf->GenerateGraph(); $error=""; } else $error=$httperf->error; } } else $error=$error_message; if(strcmp($error,"")) { $httperf->DrawMessage($error); $httperf->GenerateGraph(); } } else { ?> <HTML> <HEAD> <TITLE>HTTPerf - HTTP Performance test evaluation</TITLE> </HEAD> <BODY BGCOLOR="silver" ONLOAD="PageLoad()"> <H1><CENTER>HTTPerf - HTTP Performance test evaluation</CENTER></H1> <HR> <? if($doit) { echo "<SCRIPT LANGUAGE=Javascript TYPE=\"text/javascript\">\n<!--\n"; echo "function PageLoad()\n{\n}\n"; echo "//-->\n</SCRIPT>\n<NOSCRIPT>\n<!-- dummy comment for user agents without Javascript support enabled -->\n</NOSCRIPT>\n"; echo "<H2><CENTER>Test results</CENTER></H2>\n"; flush(); if(!strcmp($hog,"2") && $connections!=1) echo "<CENTER><TABLE>\n<TR>\n<TH VALIGN=top><FONT SIZE=\"-1\">Response<BR>\nTime (s)</FONT></TD>\n<TD><IMG ALT=\"Please wait while the results are being computed.\" SRC=\"$PHP_SELF?url=".UrlEncode($url)."&hog=$hog&connections=$connections&steps=$steps&width=".$httperf->width."&height=".$httperf->height."&doit=Test&graphic=/httperf.gif\" WIDTH=".$httperf->width." HEIGHT=".$httperf->height."></TD>\n</TR>\n<TD> </TD>\n<TH><CENTER><FONT SIZE=\"-1\">Number of simultaneous connections</FONT></CENTER></TD>\n</TR>\n</TABLE></CENTER>\n"; else { if(($error=MakeTests(&$results,&$output))=="") echo "<PRE>",implode("\n",$output),"</PRE>"; else echo "<P><CENTER>$error</CENTER>\n"; } echo "<HR>\n"; } $httperf_form->AddDataPart("<CENTER><TABLE BORDER>\n"); if($error_message!="") { $httperf_form->AddDataPart("<TR>\n<TH ALIGN=left BGCOLOR=orange><UL>\n<LI><FONT SIZE=\"+1\">$error_message</FONT></LI>\n"); if(count($verify)>1) $httperf_form->AddDataPart("<LI><FONT SIZE=\"+1\">Verify also the fields marked with [Verify]</FONT></LI>\n"); $httperf_form->AddDataPart("</UL>\n</TH>\n</TR>\n"); Reset($verify); $focus=Key($verify); } else $focus="url"; $httperf_form->AddDataPart("<TR>\n<TD>\n<CENTER><TABLE>\n"); $httperf_form->AddDataPart("<TR>\n<TH ALIGN=right>Test URL:</TH><TD>"); $httperf_form->AddInputPart("url"); if(IsSet($verify["url"])) $httperf_form->AddDataPart(" [Verify]</TD></TR>\n"); else $httperf_form->AddDataPart("</TD>\n</TR>\n"); $httperf_form->AddDataPart("<TR>\n<TH ALIGN=right>Number of connections:</TH><TD>"); $httperf_form->AddInputPart("connections"); if(IsSet($verify["connections"])) $httperf_form->AddDataPart(" [Verify]</TD></TR>\n"); else $httperf_form->AddDataPart("</TD>\n</TR>\n"); $httperf_form->AddDataPart("<TR>\n<TH ALIGN=right>Type of test connections:</TH><TD>"); $httperf_form->AddInputPart("hog"); if(IsSet($verify["hog"])) $httperf_form->AddDataPart(" [Verify]</TD></TR>\n"); else $httperf_form->AddDataPart("</TD>\n</TR>\n"); $httperf_form->AddDataPart("<TR>\n<TH COLSPAN=3>Graphical results</TD>\n</TR>\n"); $httperf_form->AddDataPart("<TR>\n<TH ALIGN=right>Plot steps:</TH><TD>"); $httperf_form->AddInputPart("steps"); if(IsSet($verify["steps"])) $httperf_form->AddDataPart(" [Verify]</TD></TR>\n"); else $httperf_form->AddDataPart("</TD>\n</TR>\n"); $httperf_form->AddDataPart("<TR>\n<TH ALIGN=right>Pixel width:</TH><TD>"); $httperf_form->AddInputPart("width"); if(IsSet($verify["width"])) $httperf_form->AddDataPart(" [Verify]</TD></TR>\n"); else $httperf_form->AddDataPart("</TD>\n</TR>\n"); $httperf_form->AddDataPart("<TR>\n<TH ALIGN=right>Pixel height:</TH><TD>"); $httperf_form->AddInputPart("height"); if(IsSet($verify["height"])) $httperf_form->AddDataPart(" [Verify]</TD></TR>\n"); else $httperf_form->AddDataPart("</TD>\n</TR>\n"); $httperf_form->AddDataPart("<TR>\n<TD COLSPAN=3><HR></TD>\n</TR>\n"); $httperf_form->AddDataPart("<TR>\n<TD COLSPAN=3 ALIGN=center>"); $httperf_form->AddInputPart("doit"); $httperf_form->AddDataPart("</TD>\n</TR>\n"); $httperf_form->AddDataPart("</TABLE></CENTER>\n</TD>\n</TR>\n</TABLE></CENTER>\n"); if(!$doit) { $httperf_form->AddFunction(array( "Function"=>"PageLoad", "Type"=>"focus", "Element"=>$focus )); } $httperf_form->Output(array( "Function"=>"Output", "EndOfLine"=>"\n" )); ?> </BODY> </HTML> <? } ?>