Skip to content

Commit dedd2b0

Browse files
authored
Create test.php
1 parent 32c15ca commit dedd2b0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/* test.php 4 log.inc.php */
3+
const DEBUG=true;
4+
require_once 'log.inc.php';
5+
$messages = file('test_messages.txt');
6+
$options = array(
7+
'path' => '.', // path to the logfile ('.' = logfile life in same directory)
8+
'filename' => 'log', // main name, _ and date will be added
9+
'syslog' => false, // true = use system log function (works only in txt format)
10+
'filePermission' => 0644, // or 0777
11+
'maxSize' => 0.002, // in MB
12+
'format' => 'htm', // use txt, csv or htm
13+
'template' => 'barecss', // for htm format only: plain, terminal or barecss
14+
'timeZone' => 'UTC', // UTC or what you like
15+
'dateFormat' => 'Y-m-d H:i:s', // see http://php.net/manual/en/function.date.php
16+
'backtrace' => true, // true = slower but with line number of call
17+
);
18+
$log = new log($options);
19+
#$log->maxSize(10);
20+
$sleep = 0;
21+
for ($i=0; $i<7; ++$i) {
22+
$index = array_rand($messages,1);
23+
$status = intval(rand(1,9).'00');
24+
$log->write(rtrim($messages[$index]),$status);
25+
$index = array_rand($messages,1);
26+
$status = intval(rand(1,9).'00');
27+
$log->write(rtrim($messages[$index]),$status);
28+
$index = array_rand($messages,1);
29+
$status = intval(rand(1,9).'00');
30+
$log->write(rtrim($messages[$index]),$status);
31+
$sleep = $sleep + 0.3;
32+
usleep(300000); // 0.3 seconds
33+
}
34+
echo 'Runtime: '.number_format((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT']-$sleep),3);

0 commit comments

Comments
 (0)