Re: [PHP] Re: oop too slow

2004-08-19 Thread Yann Larrivee
You could simply recall the constructor if the object exist.

This way you do not create the objects for every data entry you have and
aviously it will use less ressources.

Also like someone else told you, Get a Debuger! It will point out the
slow part of your code.

For example i had 30 000 lines of code in php5 oo (templating system +
e-com) to generate a page it would take 0.3 seconds.
I concider this as not too bad.


Yann


On Thu, 2004-08-19 at 07:26, Krzysztof Gorzelak wrote:
> > > Each object gets data from mysql by itself. The generation time of 1
> > > category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as
> I
> > > said more than a 1s (on quite fast machine). How can this model be
> improved?
> >
> > Why are you doing 300(!!!) mysql queries?
> > I guess you can retrieve the same data with much less queries.
> > 300 queries are slow ... not OOP.
> >
> 
> Well, I changed my script a little for tests and turned off the queries. Now
> I'm setting some defaults data to those 300 objects but it's still too slow.
> I create for every value, key and product a different object so it's in fact
> 30*10*5 objects. Then I run __toString() method one by one and generate my
> page. Is it proper to creating a separate objects for all values ? It makes
> my code much more easy...
> 
> Krzysztof Gorzelak
> [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: oop too slow

2004-08-19 Thread Jay Blanchard
[snip]
> [snip]
> Yes it does. Do you think it's not so slow ?
>
> > [snip]
> > Well, I changed my script a little for tests and turned off the
> queries.
> > Now
> > I'm setting some defaults data to those 300 objects but it's still
too
> > slow.
> > I create for every value, key and product a different object so it's
> in
> > fact
> > 30*10*5 objects. Then I run __toString() method one by one and
> generate
> > my
> > page. Is it proper to creating a separate objects for all values ?
It
> > makes
> > my code much more easy...
> > [/snip]
> >
> > So let me see if I understand. It takes 1.2 seconds to generate 1500
> > objects (30*10*5)?
> >
> [/snip]
>
> How large are the objects? I do not think that this is too slow. How
> fast do you think it should be?
>
As fast as java is. Object are as simple as String objects in Java.
There
are only few methods, constructor and __soString. It should get data
from
base and return one line of html code.
[/snip]

You cannot compare JAVA to PHP because the methodologies are so
different. And personally I find Java to be terribly slow when working
with externally stored data. We have pretty much stopped developing in
Java


P.S. Always reply to the list, not directly to someone unless they ask
you to.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: oop too slow

2004-08-19 Thread Jay Blanchard
[snip]
Yes it does. Do you think it's not so slow ?

> [snip]
> Well, I changed my script a little for tests and turned off the
queries.
> Now
> I'm setting some defaults data to those 300 objects but it's still too
> slow.
> I create for every value, key and product a different object so it's
in
> fact
> 30*10*5 objects. Then I run __toString() method one by one and
generate
> my
> page. Is it proper to creating a separate objects for all values ? It
> makes
> my code much more easy...
> [/snip]
> 
> So let me see if I understand. It takes 1.2 seconds to generate 1500
> objects (30*10*5)? 
> 
[/snip]

How large are the objects? I do not think that this is too slow. How
fast do you think it should be?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: oop too slow

2004-08-19 Thread Jay Blanchard
[snip]
Well, I changed my script a little for tests and turned off the queries.
Now
I'm setting some defaults data to those 300 objects but it's still too
slow.
I create for every value, key and product a different object so it's in
fact
30*10*5 objects. Then I run __toString() method one by one and generate
my
page. Is it proper to creating a separate objects for all values ? It
makes
my code much more easy...
[/snip]

So let me see if I understand. It takes 1.2 seconds to generate 1500
objects (30*10*5)? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: oop too slow

2004-08-19 Thread Krzysztof Gorzelak
> > Each object gets data from mysql by itself. The generation time of 1
> > category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as
I
> > said more than a 1s (on quite fast machine). How can this model be
improved?
>
> Why are you doing 300(!!!) mysql queries?
> I guess you can retrieve the same data with much less queries.
> 300 queries are slow ... not OOP.
>

Well, I changed my script a little for tests and turned off the queries. Now
I'm setting some defaults data to those 300 objects but it's still too slow.
I create for every value, key and product a different object so it's in fact
30*10*5 objects. Then I run __toString() method one by one and generate my
page. Is it proper to creating a separate objects for all values ? It makes
my code much more easy...

Krzysztof Gorzelak
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: oop too slow

2004-08-19 Thread Krzysztof Gorzelak

> > Each object gets data from mysql by itself. The generation time of 1
> > category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as
I
> > said more than a 1s (on quite fast machine). How can this model be
improved?
>
> Why are you doing 300(!!!) mysql queries?
> I guess you can retrieve the same data with much less queries.
> 300 queries are slow ... not OOP.
>

Well, I changed my script a little for tests and turned off the queries. Now
I'm setting some defaults data to those 300 objects but it's still too slow.
I create for every value, key and product a different object so it's in fact
30*10*5 objects. Then I run __toString() method one by one and generate my
page. Is it proper to creating a separate objects for all values ? It makes
my code much more easy...

Krzysztof Gorzelak
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: oop too slow

2004-08-19 Thread Aidan Lister
Krzysztof,

Take a look at some PHP Profiling extensions, such as Advanced PHP Debugger
or XDebug. This will help you locate the slow parts of your script.



"Krzysztof Gorzelak" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi
> I'm trying my new php5 script, but it takes about 1.2s to generate my
page.
> That is, how my oop model looks like :
>
> [category]
> |||
> [photo]  [desc]   [products]
>
>
> [products]
> |
> [product]
> |||
> [photo] [desc] [keys]
>
>
> [keys]
> |
> [key]
> |
> [values]
> |
> [value]
>
> Each object gets data from mysql by itself. The generation time of 1
> category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I
> said more than a 1s (on quite fast machine). How can this model be
improved?
> Do I create too many objects ? What are the oop solutions for such problem
?
>
> I also use an extra table to create many-to-many relation betwean a
product
> and a key. Is this the only way in mysql ?
>
> [product]
> |
> [product_id, key_id]
> |
> [key]
>
>
> Thanks a lot help
> Krzysztof Gorzelak
> [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: oop too slow

2004-08-19 Thread Angelo Zanetti
maybe you can rewrite your SQL statements in a way that will improve
retrieval time. Google for it.
things like select * from ... when you are not using all fields is bad
practise. there are many others.

Angelo

>>> Thomas Seifert <[EMAIL PROTECTED]> 8/19/2004 11:33:05 AM >>>
On Thu, 19 Aug 2004 11:21:16 +0200, Krzysztof Gorzelak wrote:


> Each object gets data from mysql by itself. The generation time
of 1
> category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes
as I
> said more than a 1s (on quite fast machine). How can this model be
improved?

Why are you doing 300(!!!) mysql queries?
I guess you can retrieve the same data with much less queries.
300 queries are slow ... not OOP.


thomas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php 


Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: oop too slow

2004-08-19 Thread Thomas Seifert
On Thu, 19 Aug 2004 11:21:16 +0200, Krzysztof Gorzelak wrote:


> Each object gets data from mysql by itself. The generation time of 1
> category [30 products, 10 keys, 5 values ~= 300 mysql queries] takes as I
> said more than a 1s (on quite fast machine). How can this model be improved?

Why are you doing 300(!!!) mysql queries?
I guess you can retrieve the same data with much less queries.
300 queries are slow ... not OOP.


thomas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php