Return to getrusage_variation1.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / general_functions |
1.1 misho 1: --TEST-- 2: Test getrusage() function : usage variation - diff data types as $who arg 3: --SKIPIF-- 4: <?php 5: if( substr(PHP_OS, 0, 3) == "WIN" ) 6: die("skip.. Do not run on Windows"); 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: 21: echo "*** Testing getrusage() : usage variations ***\n"; 22: 23: //get an unset variable 24: $unset_var = 10; 25: unset ($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; 69: foreach($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 -- 81: User time used (microseconds) %d 82: 83: -- Iteration 2 -- 84: User time used (microseconds) %d 85: 86: -- Iteration 3 -- 87: User time used (microseconds) %d 88: 89: -- Iteration 4 -- 90: User time used (microseconds) %d 91: 92: -- Iteration 5 -- 93: User time used (microseconds) %d 94: 95: -- Iteration 6 -- 96: User time used (microseconds) %d 97: 98: -- Iteration 7 -- 99: User time used (microseconds) %d 100: 101: -- Iteration 8 -- 102: User time used (microseconds) %d 103: 104: -- Iteration 9 -- 105: User time used (microseconds) %d 106: 107: -- Iteration 10 -- 108: User time used (microseconds) %d 109: 110: -- Iteration 11 -- 111: User time used (microseconds) %d 112: 113: -- Iteration 12 -- 114: User time used (microseconds) %d 115: 116: -- Iteration 13 -- 117: User time used (microseconds) %d 118: 119: -- Iteration 14 -- 120: User time used (microseconds) %d 121: 122: -- Iteration 15 -- 123: User time used (microseconds) %d 124: 125: -- Iteration 16 -- 126: User time used (microseconds) %d 127: 128: -- Iteration 17 -- 129: User time used (microseconds) %d 130: 131: -- Iteration 18 -- 132: User time used (microseconds) %d 133: 134: -- Iteration 19 -- 135: User time used (microseconds) %d 136: 137: -- Iteration 20 -- 138: User time used (microseconds) %d 139: 140: -- Iteration 21 -- 141: User time used (microseconds) %d 142: ===DONE===