1--TEST--
2Test getrusage() function : usage variation - diff data types as $who arg
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only");
6if (!function_exists("getrusage")) die("skip");
7?>
8--FILE--
9<?php
10/* Prototype  :  array getrusage  ([ int $who  ] )
11 * Description: Gets the current resource usages
12 * Source code: ext/standard/microtime.c
13 * Alias to functions:
14 */
15
16
17/*
18 * Pass different data types as $who argument to test behaviour of getrusage()
19 */
20
21echo "*** Testing getrusage() : usage variations ***\n";
22
23//get an unset variable
24$unset_var = 10;
25unset ($unset_var);
26
27
28// unexpected values to be passed to $stream_id argument
29$inputs = array(
30
31       // int data
32/*1*/  0,
33       1,
34       12345,
35       -2345,
36
37       // float data
38/*5*/  10.5,
39       -10.5,
40       12.3456789000e10,
41       12.3456789000E-10,
42       .5,
43
44       // null data
45/*10*/ NULL,
46       null,
47
48       // boolean data
49/*12*/ true,
50       false,
51       TRUE,
52       FALSE,
53
54       // string data
55/*16*/ "0",
56       '1',
57       "1232456",
58       "1.23E4",
59
60       // undefined data
61/*20*/ @$undefined_var,
62
63       // unset data
64/*21*/ @$unset_var,
65);
66
67// loop through each element of $inputs to check the behavior of getrusage()
68$iterator = 1;
69foreach($inputs as $input) {
70  echo "\n-- Iteration $iterator --\n";
71  $res = getrusage($input);
72  echo "User time used (microseconds) " . $res["ru_utime.tv_usec"] . "\n";
73  $iterator++;
74}
75?>
76===DONE===
77--EXPECTF--
78*** Testing getrusage() : usage variations ***
79
80-- Iteration 1 --
81User time used (microseconds) %d
82
83-- Iteration 2 --
84User time used (microseconds) %d
85
86-- Iteration 3 --
87User time used (microseconds) %d
88
89-- Iteration 4 --
90User time used (microseconds) %d
91
92-- Iteration 5 --
93User time used (microseconds) %d
94
95-- Iteration 6 --
96User time used (microseconds) %d
97
98-- Iteration 7 --
99User time used (microseconds) %d
100
101-- Iteration 8 --
102User time used (microseconds) %d
103
104-- Iteration 9 --
105User time used (microseconds) %d
106
107-- Iteration 10 --
108User time used (microseconds) %d
109
110-- Iteration 11 --
111User time used (microseconds) %d
112
113-- Iteration 12 --
114User time used (microseconds) %d
115
116-- Iteration 13 --
117User time used (microseconds) %d
118
119-- Iteration 14 --
120User time used (microseconds) %d
121
122-- Iteration 15 --
123User time used (microseconds) %d
124
125-- Iteration 16 --
126User time used (microseconds) %d
127
128-- Iteration 17 --
129User time used (microseconds) %d
130
131-- Iteration 18 --
132User time used (microseconds) %d
133
134-- Iteration 19 --
135User time used (microseconds) %d
136
137-- Iteration 20 --
138User time used (microseconds) %d
139
140-- Iteration 21 --
141User time used (microseconds) %d
142===DONE===
143