Older Contests
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP ContestsOlder Contests

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old July 23rd, 2002, 12:20 PM
swush swush is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 5 swush User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
oop

hi,
i recently finished my script which producesdecent results but is rather slow. so i tested a bit and discovered that the use of objects/classes was the reason for it. now i'm thinking about reducing the oop-elements. actually i don't really want to, because my code is now pretty easy to read und debug.

how did u write ur scripts? many classes, no one at all?


Reply With Quote
  #2  
Old July 23rd, 2002, 09:23 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: oop

~10 functions.

My program sux though with only 431 score max on the first wordlist.

I'm thinking of redoing the way I choose words to place.

Reply With Quote
  #3  
Old July 30th, 2002, 05:27 PM
gatopeich gatopeich is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Madrid, Spain / Boston, MA
Posts: 96 gatopeich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 54 sec
Reputation Power: 2
Send a message via Yahoo to gatopeich
RE: oop

oops?... OOP!
I think the objects/classes are not the slow thing with PHP, but the fact that when you ask for an array of 1000 integers, you get an array of 1000 untyped variables with integer values. I suppose they have a lot of overhead and a copy operation (the heaviest in crossword solving) becomes 1000 memory allocations + 1000 object creations.
I overcome the matter by using a single 400 char string for the entire crossword board. This is tricky; but keeps memory usage & management at low.
Also I try to use reference assignment everywhere as possible; but this gives unexpected results many times. I still don't understand references well.
Other form of speed-improvement is to analize conditionals and making the heavier operations on the least usual case when possible, as in:

1> $tmp=$this;
2> if ($tmp->find_better_solution())
3> $this = $tmp; // Heavy CPU use for copying

is faster than

1> $backup=$this;
2> if (!($this->find_better_solution()))
3> $this = $tmp; // Heavy CPU use for copying

supposing that to find a better solution is less usual than not finding it.

Also, I found that adding some 'unset($tmp)' with objects not needed improved the speed a lot.

Ow, I am so boring. >-(

Reply With Quote
  #4  
Old July 30th, 2002, 11:31 PM
swush swush is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 5 swush User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: oop

thanks for ur thoughts. i think too that memory allocation is a very time - consuming matter in general. but i don't believe this is what makes OOP in PHP slow. i rather think object creation is somewhat slow.
btw in the php manual it says references are not faster than copies since 4.0 .
anyway i'd be happy if zend spent some time to improve the object oriented side of php. not only speed matters, but access restriction and error handling maybe like in java would be really neat.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP ContestsOlder Contests > oop


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT