[PHP-DEV] My personal parsing tester From: Mark J. Hershenson (markhers <email protected>)
Date: 12/12/00

I devised a quick and dirty way of checking out what a server IS and is NOT
parsing. I have attached a copy of the file, and you can download it from:

http://www.green-ant.com/parse-test/parse-test.txt

(Be sure to change the extension to something that your web server
recognizes when you download it, ok? :P)

This script is intended to query a server and request a document using
fopen("...", "r").

The script uses these variables:

 * $totalExec - total number of times to query the server
 * $accessProtocol (HTTP, FTP...)
 * $serverName - HTTP host name (php.net, for example)
 * $fileName - the path to the file you wish to test ("/" for example in the
URL http://www.php.net/)
 
For simplicity's sake, as databases were of course designed to handle the
sorting of and manipulation of data, I figured I'd just use MySQL to do the
analysis at the end of it all. So each iteration makes a single insert call
to a MySQL database (no reason to stay with MySQL, just the DB I used).

At the end, relevant data is pulled and displayed on screen.

--

Note: Every iteration prints a single space (inside of an HTML comment) to the screen. The reason for this is to avoid some browser's "timing out" policies, which can abort their display if they have no received data in the past 30 seconds.

Frankly, this seemed the most elegant solution to the problem. I went with 1 space per connection as opposed to one per $x connections as some web servers are actually quite slow, and this could (conceivably :P) also spark the diminished bandwidth "timing out."

--

My personal advice:

Keep that which you parse simple. It will make it simpler to hit the server hard and repeatedly, as you will likely want to hit the server in the 1,000-100,000 time range. This will also lessen the bandwidth you use, and the amount of disk space you use to store the result in your database server.

My own example was:

<?php

echo (2+2); ?>

Which should, of course, return "4". (It's also only 1 byte of returned data, headers excluded, which is handy on the bandwidth.)

--

Special note:

There are a number of equivalent ways to go here. You can you use fsockopen and do the same thing, or use "lynx -source", or any of a number of other tools, including wget.

I chose fopen("", "") because I didn't have to mess around with HTTP headers, but that is by no means a reason not to go another way, or a well-structured argument against other means.

--

MySQL table:

CREATE TABLE access ( URL varchar(128) NOT NULL, result text NOT NULL, accessTime double(16,4) DEFAULT '0.0000' NOT NULL, accessID int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (accessID) );

You will of course have to manage for yourself a user account and proper permissions to run the test.

--

I know this is just a start, but it may be of help to some of you to enumerate your parsing issues.

Hope it helps!

Mark J. Hershenson markhers <email protected> http://www.green-ant.com/

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>