File: real.phpt

package info (click to toggle)
php-excimer 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: ansic: 2,513; xml: 233; php: 82; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 680 bytes parent folder | download | duplicates (5)
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
--TEST--
ExcimerProfiler real time profile
--SKIPIF--
<?php if (!extension_loaded("excimer")) print "skip"; ?>
--FILE--
<?php

function foo() {
	usleep(100000);
}

$profiler = new ExcimerProfiler;
$profiler->setEventType(EXCIMER_REAL);
$profiler->setPeriod(0.1);

for ($j = 0; $j < 3; $j++) {
	$profiler->start();
	for ($i = 0; $i < 10; $i++) {
		foo();
	}
	$profiler->stop();
}

$log = $profiler->flush();
$found = 0;
foreach ($log as $entry) {
	$trace = $entry->getTrace();
	if (isset($trace[0]['function'])
		&& $trace[0]['function'] === 'foo'
		&& !isset($trace[1]['function']))
	{
		$found++;
	}
}
if ($found > 11) {
	echo "OK\n";
} else {
	echo "FAILED\n";
}

--EXPECT--
OK