cvs: pear /Log_Parser/tests test.php
| From: | Xavier Noguer Gallego | Date: | Wed, 24 Sep 2003 15:26:41 +0000 |
| Subject: | cvs: pear /Log_Parser/tests test.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13061@lists.php.net to get a copy of this message | ||
xnoguer Wed Sep 24 11:26:41 2003 EDT
Modified files:
/pear/Log_Parser/tests test.php
Log:
committing for toby
Index: pear/Log_Parser/tests/test.php
diff -u pear/Log_Parser/tests/test.php:1.1 pear/Log_Parser/tests/test.php:1.2
--- pear/Log_Parser/tests/test.php:1.1 Mon May 19 19:16:10 2003
+++ pear/Log_Parser/tests/test.php Wed Sep 24 11:26:40 2003
@@ -1,35 +1,60 @@
<?php
+ // This is for the performance test
+ require_once 'Benchmark/Timer.php';
+ $timer =& new Benchmark_Timer(false);
+ $timer->start();
- require_once 'Parser.php';
- echo "Hallo";
- $test = new Log_Parser_Config_Namespace();
- $config = new Log_Parser_Config('Parser/apache_access.xml');
+ require_once 'Log_Parser/Parser.php';
+ require_once 'Log_Parser/Parser/Filter/Filter_Regex.php';
+ require_once 'Log_Parser/Parser/Filter/Filter_Personal.php';
+ set_time_limit(120);
- $log = new Log_Parser('tobias/access.log', $config);
- $ret = $log->parse(0, 3716);
- var_dump($log);
-
- /*
-
- require_once 'Log_Parser.php';
- require_once 'Log_Parser_Config.php';
+ // Create a configuration for linux system log
+ // $config = new
Log_Parser_Config('/usr/share/pear/Log_Parser/data/linux_messages.xml');
+ // Create a configuration for apache access log
+ $config = new Log_Parser_Config('/usr/share/pear/Log_Parser/data/apache_access.xml');
+
+ // Benchmarking
+ $timer->setMarker('After Config initialisation');
+
+ // Create a parser for linux system log
+ // $log = new Log_Parser('/var/log/messages', $config);
+ // Create a parser for apache access log
+ $log = new Log_Parser('/var/log/httpd/access_log.1', $config);
+
+ // Benchmarking
+ $timer->setMarker('After Parser initialisation');
+
+ // Test for static filter
+ // $filter = new Log_Parser_Filter_Regex();
+ // $filter->addCondition('standard', 'method', '/POST/');
+ // $filter->addCondition('standard', 'file',
'/^\/infonet\//');
+
+ // Test for dynamic filter
+ $filter = new Log_Parser_Filter_Personal();
+
+ // Benchmarking
+ $timer->setMarker('After Filter initialisation');
+
+ // Add the filter to the parser
+ $log->addFilter($filter);
+
+ // Parser 1000 lines of the log
+ $ret = $log->parse(0, 5000);
+
+ // Benchmarking
+ $timer->setMarker('After parsing');
+
+ // Dump different objects from above
+ // var_dump($test);
+ // var_dump($config);
+ // var_dump($log);
+ // var_dump($ret);
+
+ // Benchmarking
+ $timer->setMarker('After output');
- $config = new Log_Parser_Config('tobias/apache_access.xml');
- $log = new Log_Parser('tobias/access.log', $config);
- $ret = $log->parse(0, 3716);
- if (PEAR::isError($ret)) {
- die($ret->getMessage()."\n");
- }
- else
- {
- while (($line = $log->nextLine()) !== false) {
- echo "{$line['ip']}\n";
- }
- echo "done\n";
- }
-
- */
-
+ $timer->display();
?>