Re: to all Gurus -> I need some HELP

From: Date: Wed, 29 Nov 2000 19:20:07 +0000
Subject: Re: to all Gurus -> I need some HELP
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-27857@lists.php.net to get a copy of this message
From: Joe Stump <joe@earth.care2.com> > I can't IMAGINE what kind of code is taking 10 seconds per user to parse. That > is borderline ridiculous. I would say it's either a.) you're running this on > a 486 b.) not very optimized code or c.) something that shouldn't be run from > a web app. Well, yes it's not a rocket comp =) (Cyrix 150+), but I am allways testing on a slower machine to see, when the larger one is going to the limit. You wanna have the code? Okay, here we go: (this code is only a snippet the right one should store and generate XML files) <? $starttime = mtime(); $ocount = 0; class tree { var $children; var $name; var $value; function tree($name, $value="") { global $ocount; $this->name = $name; $this->value = $value; $ocount++; } function addChild($name, $value="") { $nr = count($this->children); $this->children[$nr] = new tree($name, $value); return $nr; } function getASCII($insert="") { $str = "$insert<$this->name>$this->value</$this->name>\n"; $insert.="\t"; for($x=0;$x<count($this->children);$x++) $str.=$this->children[$x]->getASCII($insert); return $str; } } $tree = new tree("mother"); buildTree($tree, 4, 10); echo delay()." - $ocount<br>\n"; flush(); $str=$tree->getASCII(); echo delay()." - $ocount<br>\n"; function buildTree(&$tree, $level, $count) { if($level==0) return; for($x=0;$x<$count;$x++) { $nr = $tree->addChild("child$level$x"); buildTree($tree->children[$nr], $level-1, $count); } } function delay() { global $starttime; return mtime() - $starttime; } function me(){ $m = explode(" ",microtime()); return ($m[1] + $m[0]); } ?>

« previous php.general (#27857) next »