Guest User

Untitled

a guest
Jul 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. <?php
  2. if (function_exists("date_default_timezone_set")) {
  3. date_default_timezone_set("UTC");
  4. }
  5.  
  6.  
  7. /****/
  8.  
  9. function hallo($a) {
  10. }
  11.  
  12. function simpleucall() {
  13. for ($i = 0; $i < 1000000; $i++)
  14. hallo("hallo");
  15. }
  16.  
  17. /****/
  18.  
  19. function simpleudcall() {
  20. for ($i = 0; $i < 1000000; $i++)
  21. hallo2("hallo");
  22. }
  23.  
  24. function hallo2($a) {
  25. }
  26.  
  27. /****/
  28.  
  29. function mandel() {
  30. $w1=50;
  31. $h1=150;
  32. $recen=-.45;
  33. $imcen=0.0;
  34. $r=0.7;
  35. $s=0; $rec=0; $imc=0; $re=0; $im=0; $re2=0; $im2=0;
  36. $x=0; $y=0; $w2=0; $h2=0; $color=0;
  37. $s=2*$r/$w1;
  38. $w2=40;
  39. $h2=12;
  40. for ($y=0 ; $y<=$w1; $y=$y+1) {
  41. $imc=$s*($y-$h2)+$imcen;
  42. for ($x=0 ; $x<=$h1; $x=$x+1) {
  43. $rec=$s*($x-$w2)+$recen;
  44. $re=$rec;
  45. $im=$imc;
  46. $color=1000;
  47. $re2=$re*$re;
  48. $im2=$im*$im;
  49. while( ((($re2+$im2)<1000000) && $color>0)) {
  50. $im=$re*$im*2+$imc;
  51. $re=$re2-$im2+$rec;
  52. $re2=$re*$re;
  53. $im2=$im*$im;
  54. $color=$color-1;
  55. }
  56. if ( $color==0 ) {
  57. //print "_";
  58. } else {
  59. //print "#";
  60. }
  61. }
  62. //print "<br>";
  63. flush();
  64. }
  65. }
  66.  
  67. /****/
  68.  
  69. function mandel2() {
  70. $b = " .:,;!/>)|&IH%*#";
  71. //float r, i, z, Z, t, c, C;
  72. for ($y=30; /*printf("\n"),*/ $C = $y*0.1 - 1.5, $y--;){
  73. for ($x=0; $c = $x*0.04 - 2, $z=0, $Z=0, $x++ < 75;){
  74. for ($r=$c, $i=$C, $k=0; $t = $z*$z - $Z*$Z + $r, $Z = 2*$z*$Z + $i, $z=$t, $k<5000; $k++)
  75. if ($z*$z + $Z*$Z > 500000) break;
  76. //echo $b[$k%16];
  77. }
  78. }
  79. }
  80.  
  81. /****/
  82.  
  83. function Ack($m, $n){
  84. if($m == 0) return $n+1;
  85. if($n == 0) return Ack($m-1, 1);
  86. return Ack($m - 1, Ack($m, ($n - 1)));
  87. }
  88.  
  89. function ackermann($n) {
  90. $r = Ack(3,$n);
  91. print "Ack(3,$n): $r\n";
  92. }
  93.  
  94. /****/
  95.  
  96. function ary($n) {
  97. for ($i=0; $i<$n; $i++) {
  98. $X[$i] = $i;
  99. }
  100. for ($i=$n-1; $i>=0; $i--) {
  101. $Y[$i] = $X[$i];
  102. }
  103. $last = $n-1;
  104. print "$Y[$last]\n";
  105. }
  106.  
  107. /****/
  108.  
  109. function ary2($n) {
  110. for ($i=0; $i<$n;) {
  111. $X[$i] = $i; ++$i;
  112. $X[$i] = $i; ++$i;
  113. $X[$i] = $i; ++$i;
  114. $X[$i] = $i; ++$i;
  115. $X[$i] = $i; ++$i;
  116.  
  117. $X[$i] = $i; ++$i;
  118. $X[$i] = $i; ++$i;
  119. $X[$i] = $i; ++$i;
  120. $X[$i] = $i; ++$i;
  121. $X[$i] = $i; ++$i;
  122. }
  123. for ($i=$n-1; $i>=0;) {
  124. $Y[$i] = $X[$i]; --$i;
  125. $Y[$i] = $X[$i]; --$i;
  126. $Y[$i] = $X[$i]; --$i;
  127. $Y[$i] = $X[$i]; --$i;
  128. $Y[$i] = $X[$i]; --$i;
  129.  
  130. $Y[$i] = $X[$i]; --$i;
  131. $Y[$i] = $X[$i]; --$i;
  132. $Y[$i] = $X[$i]; --$i;
  133. $Y[$i] = $X[$i]; --$i;
  134. $Y[$i] = $X[$i]; --$i;
  135. }
  136. $last = $n-1;
  137. print "$Y[$last]\n";
  138. }
  139.  
  140. /****/
  141.  
  142. function ary3($n) {
  143. for ($i=0; $i<$n; $i++) {
  144. $X[$i] = $i + 1;
  145. $Y[$i] = 0;
  146. }
  147. for ($k=0; $k<1000; $k++) {
  148. for ($i=$n-1; $i>=0; $i--) {
  149. $Y[$i] += $X[$i];
  150. }
  151. }
  152. $last = $n-1;
  153. print "$Y[0] $Y[$last]\n";
  154. }
  155.  
  156. /****/
  157.  
  158. function fibo_r($n){
  159. return(($n < 2) ? 1 : fibo_r($n - 2) + fibo_r($n - 1));
  160. }
  161.  
  162. function fibo($n) {
  163. $r = fibo_r($n);
  164. print "$r\n";
  165. }
  166.  
  167. /****/
  168.  
  169. function hash1($n) {
  170. for ($i = 1; $i <= $n; $i++) {
  171. $X[dechex($i)] = $i;
  172. }
  173. $c = 0;
  174. for ($i = $n; $i > 0; $i--) {
  175. if ($X[dechex($i)]) { $c++; }
  176. }
  177. print "$c\n";
  178. }
  179.  
  180. /****/
  181.  
  182. function hash2($n) {
  183. for ($i = 0; $i < $n; $i++) {
  184. $hash1["foo_$i"] = $i;
  185. $hash2["foo_$i"] = 0;
  186. }
  187. for ($i = $n; $i > 0; $i--) {
  188. foreach($hash1 as $key => $value) $hash2[$key] += $value;
  189. }
  190. $first = "foo_0";
  191. $last = "foo_".($n-1);
  192. print "$hash1[$first] $hash1[$last] $hash2[$first] $hash2[$last]\n";
  193. }
  194.  
  195. /****/
  196.  
  197. function gen_random ($n) {
  198. global $LAST;
  199. return( ($n * ($LAST = ($LAST * IA + IC) % IM)) / IM );
  200. }
  201.  
  202. function heapsort_r($n, &$ra) {
  203. $l = ($n >> 1) + 1;
  204. $ir = $n;
  205.  
  206. while (1) {
  207. if ($l > 1) {
  208. $rra = $ra[--$l];
  209. } else {
  210. $rra = $ra[$ir];
  211. $ra[$ir] = $ra[1];
  212. if (--$ir == 1) {
  213. $ra[1] = $rra;
  214. return;
  215. }
  216. }
  217. $i = $l;
  218. $j = $l << 1;
  219. while ($j <= $ir) {
  220. if (($j < $ir) && ($ra[$j] < $ra[$j+1])) {
  221. $j++;
  222. }
  223. if ($rra < $ra[$j]) {
  224. $ra[$i] = $ra[$j];
  225. $j += ($i = $j);
  226. } else {
  227. $j = $ir + 1;
  228. }
  229. }
  230. $ra[$i] = $rra;
  231. }
  232. }
  233.  
  234. function heapsort($N) {
  235. global $LAST;
  236.  
  237. define("IM", 139968);
  238. define("IA", 3877);
  239. define("IC", 29573);
  240.  
  241. $LAST = 42;
  242. for ($i=1; $i<=$N; $i++) {
  243. $ary[$i] = gen_random(1);
  244. }
  245. heapsort_r($N, $ary);
  246. printf("%.10f\n", $ary[$N]);
  247. }
  248.  
  249. /****/
  250.  
  251. function mkmatrix ($rows, $cols) {
  252. $count = 1;
  253. $mx = array();
  254. for ($i=0; $i<$rows; $i++) {
  255. for ($j=0; $j<$cols; $j++) {
  256. $mx[$i][$j] = $count++;
  257. }
  258. }
  259. return($mx);
  260. }
  261.  
  262. function mmult ($rows, $cols, $m1, $m2) {
  263. $m3 = array();
  264. for ($i=0; $i<$rows; $i++) {
  265. for ($j=0; $j<$cols; $j++) {
  266. $x = 0;
  267. for ($k=0; $k<$cols; $k++) {
  268. $x += $m1[$i][$k] * $m2[$k][$j];
  269. }
  270. $m3[$i][$j] = $x;
  271. }
  272. }
  273. return($m3);
  274. }
  275.  
  276. function matrix($n) {
  277. $SIZE = 30;
  278. $m1 = mkmatrix($SIZE, $SIZE);
  279. $m2 = mkmatrix($SIZE, $SIZE);
  280. while ($n--) {
  281. $mm = mmult($SIZE, $SIZE, $m1, $m2);
  282. }
  283. print "{$mm[0][0]} {$mm[2][3]} {$mm[3][2]} {$mm[4][4]}\n";
  284. }
  285.  
  286. /****/
  287.  
  288. function nestedloop($n) {
  289. $x = 0;
  290. for ($a=0; $a<$n; $a++)
  291. for ($b=0; $b<$n; $b++)
  292. for ($c=0; $c<$n; $c++)
  293. for ($d=0; $d<$n; $d++)
  294. for ($e=0; $e<$n; $e++)
  295. for ($f=0; $f<$n; $f++)
  296. $x++;
  297. print "$x\n";
  298. }
  299.  
  300. /****/
  301.  
  302. function sieve($n) {
  303. $count = 0;
  304. while ($n-- > 0) {
  305. $count = 0;
  306. $flags = range (0,8192);
  307. for ($i=2; $i<8193; $i++) {
  308. if ($flags[$i] > 0) {
  309. for ($k=$i+$i; $k <= 8192; $k+=$i) {
  310. $flags[$k] = 0;
  311. }
  312. $count++;
  313. }
  314. }
  315. }
  316. print "Count: $count\n";
  317. }
  318.  
  319. /****/
  320. simpleucall();
  321. simpleudcall();
  322. mandel();
  323. mandel2();
  324. ackermann(7);
  325. ary(50000);
  326. ary2(50000);
  327. ary3(2000);
  328. fibo(30);
  329. hash1(50000);
  330. print("this\r\n");
  331. hash2(500);
  332. print("makes\r\n");
  333. heapsort(20000);
  334. print("it\r\n");
  335.  
  336. print("crash\r\n");
  337. for ($ix = 0; $ix < 1; $ix++) {
  338. }
  339. print("somehow.\r\n");
  340.  
  341. ?>
Add Comment
Please, Sign In to add comment