/usr/share/php/xajax/tests/performance.php is in php-xajax 0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | <?php
if ( function_exists( 'xdebug_start_code_coverage' ) )
xdebug_start_code_coverage();
require_once dirname( dirname( dirname( __FILE__ ) ) ) . '/Benchmark/Timer.php';
$timer=new Benchmark_Timer();
$timer->start();
//require('../xajax_core/xajax.inc.php');
require( '../xajax_core/xajaxAIO.inc.php' );
$timer->setMarker( 'xajax included' );
// -- testing session serialization for xajax object
//session_start();
//
//unset($_SESSION['xjxcore']);
//
//$xajax = null;
//
//if (false == isset($_SESSION['xjxcore']))
//{
// $xajax =& new xajax();
//
// $_SESSION['xjxcore'] =& $xajax;
//}
//else
//{
// $xajax =& $_SESSION['xjxcore'];
//}
// -- end testing
$xajax=new xajax();
$xajax->registerFunction( 'argumentDecode' );
$xajax->registerFunction( 'roundTrip' );
$xajax->registerFunction( 'compress' );
$xajax->registerFunction( 'compile' );
$timer->setMarker( 'xajax constructed' );
$trips=3000;
$timer->setMarker( 'begin process request' );
$xajax->processRequest();
$timer->setMarker( 'after process request' );
function argumentDecode( $nTimes, $aArgs )
{
global $timer;
global $trips;
$objResponse=new xajaxResponse();
if ( $nTimes < $trips )
{
$nTimes+=1;
$objResponse->script( 'xajax_argumentDecode(' . $nTimes . ', jsArray);' );
$objResponse->assign( 'submittedDiv', 'innerHTML', 'Working...' );
$objResponse->append( 'submittedDiv', 'innerHTML', print_r( $aArgs, true ) );
}
else
{
$objResponse->assign( 'submittedDiv', 'innerHTML', 'Done' );
ob_start();
var_dump( xdebug_get_code_coverage());
$objResponse->append( 'submittedDiv', 'innerHTML', ob_get_clean() );
}
$timer->stop();
$objResponse->call( 'accumulateTime', $timer->timeElapsed() );
$objResponse->call( 'printTime' );
return $objResponse;
}
function roundTrip( $nTimes )
{
global $timer;
global $trips;
$objResponse=new xajaxResponse();
if ( $nTimes < $trips )
{
$nTimes+=1;
$objResponse->script( 'xajax_roundTrip(' . $nTimes . ');' );
$objResponse->assign( 'submittedDiv', 'innerHTML', 'Working...' );
}
else
{
$objResponse->assign( 'submittedDiv', 'innerHTML', 'Done' );
}
$timer->stop();
$objResponse->call( 'accumulateTime', $timer->timeElapsed() );
$objResponse->call( 'printTime' );
return $objResponse;
}
function compress( )
{
global $xajax;
$xajax->_compressSelf();
$objResponse=new xajaxResponse();
$objResponse->assign( 'submittedDiv', 'innerHTML', 'Compressed' );
return $objResponse;
}
function compile( )
{
global $xajax;
$xajax->_compile();
$objResponse=new xajaxResponse();
$objResponse->assign( 'submittedDiv', 'innerHTML', 'Compiled' );
return $objResponse;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Performance Test</title>
<?php $xajax->printJavascript( '../' ); ?>
<script type = 'text/javascript'>
nCumulativeTime = 0;
nTrips = 0;
accumulateTime = function(nTime)
{
nCumulativeTime += (nTime * 1);
nTrips += 1;
}
printTime = function()
{
xajax.$('result').innerHTML = 'Trips: ' + nTrips +
'<br />Total time: ' + nCumulativeTime +
'<br />Average time: ' + nCumulativeTime / nTrips;
}
jsArray =
{
a: [1, 2, 3, 4, 5],
b: [1, 2, 3, 4, 5, 6],
c: [1, 2, 3, 4, 5, 6, 7],
d: [1, 2, 3, 4, 5, 6, 7, 8],
e: [1, 2, 3, 4, 5, 6, 7, 8, 9],
f: [1, 2, 3, 4, 5, 6, 7, 8, 9]
};
</script>
</head>
<body>
<h2><a href = "index.php">xajax Tests</a></h2>
<h1>Redirect Test</h1>
<form id = "testForm1" onsubmit = "return false;">
<p>
<input type = 'submit' value = 'Begin argumentDecode' name = 'begin' id = 'begin'
onclick = 'nCumulativeTime = 0; nTrips=0; xajax_argumentDecode(0, jsArray); return false;' />
</p>
<p>
<input type = 'submit' value = 'Begin roundTrip' name = 'begin'
id = 'Submit1' onclick = 'nCumulativeTime = 0; nTrips=0; xajax_roundTrip(0); return false;' />
</p>
<p>
<input type = 'submit'
value = 'Compress' name = 'compress' id = 'compress' onclick = 'xajax_compress(); return false;' />
</p>
<p>
<input type = 'submit'
value = 'Compile' name = 'compile' id = 'compile' onclick = 'xajax_compile(); return false;' />
</p>
</form>
<div id = "submittedDiv">
</div>
<div id = "result">
</div>
<?php
$timer->stop();
$timer->display();
if ( function_exists( 'xdebug_get_code_coverage' ) )
var_dump( xdebug_get_code_coverage());
?>
</body>
</html>
|