For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > July 2004 > Re: [SMARTY] Smarty Light









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] Smarty Light
Pedro Teixeira

2004-07-08, 4:04 pm

I couldn't agree more.

I don't code my business logic with smarty. All the "complicated stuff",
like building the dynamic menu structures I do in a PHP business layer,
and use smarty to present already flattened structures.

I use Smarty for what it is good at: separating the business logic from
presentation and the cache mechanism.

Cheers,

Pedro Teixeira


On Thu, 2004-07-08 at 10:30, Ara Anjargolian wrote:
> Hi,
> I'm very new to this newsgroup so please excuse me if this
> has been discussed before, but is there any interest at all
> in a "Light" version of Smarty which would basically be Smarty
> with some of the more sparsely used functionality safely ripped out?
> I am building a large web app and using Smarty and I was considering
> of doing something like this. I keep hearing complaints of how Smarty
> is bloated and while I do not necessarilly share these sentiments I
> thought maybe it might be nice to have a Smarty-compatible template
> system that is smaller, more limited.
>
> For example in our templates we don't ever forsee the need to
> use:
> filters
> {section} (iterating through mulitple arrays is nice but, for us anyway,
> not essential)
> any "security" settings
> {strip}
> {capture}
> {insert}
> and a few other little things.
>
> On the otherhand I would tend to keep a few of the features
> that IMHO make Smarty Smarty such as the clever plugin architecture
> and fairly sophisticated caching system.
>
> Anyway, I just wanted to get other peoples take on what a Smarty Light
> would/should look like. I think this is a something that I will get
> around to in the next few months and could certainly make it public
> if other people would find it at all useful.
>
> Kind Regards,
> Ara

Mrak

2004-07-08, 4:04 pm

All the listed features (except sections maybe) are loaded on request
only and hence do not affect performance... moreover, if you take a
closer look at the smarty object, you can easily "turn off" features
loaded by default, hence I do not see a point in even thinking about
smarty light

regards,

alex

Pedro Teixeira wrote:
> I couldn't agree more.
>
> I don't code my business logic with smarty. All the "complicated stuff",
> like building the dynamic menu structures I do in a PHP business layer,
> and use smarty to present already flattened structures.
>
> I use Smarty for what it is good at: separating the business logic from
> presentation and the cache mechanism.
>
> Cheers,
>
> Pedro Teixeira
>
>
> On Thu, 2004-07-08 at 10:30, Ara Anjargolian wrote:
>
>
>

Monte Ohrt

2004-07-08, 4:04 pm

There have been attempts to do this before, such as:

http://sourceforge.net/projects/smarty-light/

I take no responsibility for their support ;)

Martin Braun wrote:

>Mrak sagte:
>
>
>
>i don't see any need for smarty light, but if you really want to strip
>smarty off some features, all you have to do is to delete the associated
>files.
>
>however, this shouldn't gain any perfomance, just a few KB of disk space.
>
>I'm no smarty developer, but I think ripping other functions from smarty
>would only gain perfomance during the compiling process - remember smarty
>compiles it's templates to PHP-files anyway, and compiling shouldn't
>happen all the time.
>
>just theorizing....
>
>cheers
>martin
>
>
>

Ara Anjargolian

2004-07-08, 4:04 pm

This is not a matter of just removing a few extensions. I realize
that anything in an extension is loaded on request and therefore
has no effect on performance when not used. I looked
through the compiler class and am fairly certain I can remove alot
of its heft by taking a few of the less used features out. Now
if you use an accelerator this probably won't make any difference,
but if you don't it could speed up things a decent amount.
Anyway though, I guess the best way to find out is to actually give it a
try and see if I get anywhere. I probably wont get to try this
until sometime in late August but when I do I will report back
with the results.

Thanks,
Ara Anjargolian

Martin Braun wrote:
> Mrak sagte:
>
>
>
> i don't see any need for smarty light, but if you really want to strip
> smarty off some features, all you have to do is to delete the associated
> files.
>
> however, this shouldn't gain any perfomance, just a few KB of disk space.
>
> I'm no smarty developer, but I think ripping other functions from smarty
> would only gain perfomance during the compiling process - remember smarty
> compiles it's templates to PHP-files anyway, and compiling shouldn't
> happen all the time.
>
> just theorizing....
>
> cheers
> martin

Messju Mohr

2004-07-08, 4:04 pm

On Thu, Jul 08, 2004 at 11:09:06AM -0700, Ara Anjargolian wrote:
> This is not a matter of just removing a few extensions. I realize
> that anything in an extension is loaded on request and therefore
> has no effect on performance when not used. I looked
> through the compiler class and am fairly certain I can remove alot
> of its heft by taking a few of the less used features out. Now
> if you use an accelerator this probably won't make any difference,
> but if you don't it could speed up things a decent amount.


no. you would gain hardly anything. the compiler is only run the first
time you display a template. all subsequent calls to display() for
that template use the compiled template and the compiler isn't touched
anymore.

profile the code before you start optimizing. :)

> Anyway though, I guess the best way to find out is to actually give it a
> try and see if I get anywhere. I probably wont get to try this
> until sometime in late August but when I do I will report back
> with the results.
>
> Thanks,
> Ara Anjargolian


greetings
messju


> Martin Braun wrote:
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Boots

2004-07-08, 4:04 pm

--- messju mohr <messju@lammfellpuschen.de> wrote:
> On Thu, Jul 08, 2004 at 11:09:06AM -0700, Ara Anjargolian wrote:
>
> no. you would gain hardly anything. the compiler is only run the
> first
> time you display a template. all subsequent calls to display() for
> that template use the compiled template and the compiler isn't
> touched
> anymore.
>
> profile the code before you start optimizing. :)


Plus, if you fork you own--you are on your own in-terms of keeping the
code up-to-date. Hardly seems worthwhile to me.

xo boots
Markku Niskanen

2004-07-09, 8:57 am

On Thu, 08 Jul 2004 11:09:06 -0700, you wrote:

>of its heft by taking a few of the less used features out. Now
>if you use an accelerator this probably won't make any difference,


I just reported my findings in the developer area. I removed
all whitespace and comments from the Smarty.class.php using
PHP5 function php_strip_whitespace() and the results using my
Linux/Celeron 300 was this (rough test averages, just loading
the Smarty.class.php file):

Original Smarty.class.php 0.0453 seconds
Stripped Smarty.class.php 0.0388 seconds.

The difference was around 0,0065 seconds. This way you gain
something ina non-accelerated environment without doing
any changes in code. In an opcode-cached environment there
is no difference, of course.

The stripped class was around 30 K as opposed to the
60 K of the original file and the time difference comes from
the parsing phase. After that the CPU time your application
uses will very probably depend on the nature of your code,
what features you are using. If you use simple assigns followed
by a single "display" there will be no further benefit from a
stipped-down version as the code will be identical, anyhow.

As most other writers I do not believe in any benefit that would
come from a 'light' version of Smarty. The more one uses it=20
the more features one will make use of. I know many users
do not like the "section" loops but I use them extensively as
they provide much more flexibility. It just takes some time to
understand where the clue is. The same is true about many
other features: once you use a feature you cannot live without
it :)


Markku
Thorsten Suckow-Homberg

2004-07-09, 8:57 am

Hi all,


unfortunately I couldn't follow your discussion but I guess the topic says it all.

I was thinking about using/writing a smaller derivate of the smarty class myself, since requiring 60k of code and building a huge
smarty-object is somewhat not the most performant thing one can do (specially when it comes to enterprise-application-level and 100k
users need the same script at one time).

I don't know if the suggestion was made, but what about a small file called SmartyLight.php that gives you some static functions for
checking and returning the cached version of a file?

Regards

Thorsten
Boots

2004-07-09, 4:02 pm

--- Thorsten Suckow-Homberg <ts@siteartwork.de> wrote:
> I was thinking about using/writing a smaller derivate of the smarty
> class myself, since requiring 60k of code and building a huge
> smarty-object is somewhat not the most performant thing one can do
> (specially when it comes to enterprise-application-level and 100k
> users need the same script at one time).


With all due respect, that sounds like a load of...
enterprise-application-level and 100k users? Whatever.

xo boots
Mrak

2004-07-09, 4:02 pm



Thorsten Suckow-Homberg wrote:
> enterprise-application-level and 100k
> users need the same script at one time).


I presume at that load one FOR SURE will have a dedicated server, hence
nothing stopping the symin to install Turck MMCache or Zend Accelerator.

regards,

alex
Thorsten Suckow-Homberg

2004-07-09, 4:02 pm

> With all due respect, that sounds like a load of...
> enterprise-application-level and 100k users? Whatever.


Where is your problem?

Regards

Thorsten
Thorsten Suckow-Homberg

2004-07-09, 4:02 pm

> I presume at that load one FOR SURE will have a dedicated server, hence
> nothing stopping the symin to install Turck MMCache or Zend Accelerator.


I bet you will.

Anyway, that doesn't solve the problem. Carrying around a 60 k file just for checking if a template is cached and then display it?

Regards

Thorsten
Pete M

2004-07-09, 4:02 pm

Thorsten Suckow-Homberg wrote:

> Hi all,
>
>
> unfortunately I couldn't follow your discussion but I guess the topic says it all.
>
> I was thinking about using/writing a smaller derivate of the smarty class myself, since requiring 60k of code and building a huge
> smarty-object is somewhat not the most performant thing one can do (specially when it comes to enterprise-application-level and 100k
> users need the same script at one time).
>
> I don't know if the suggestion was made, but what about a small file called SmartyLight.php that gives you some static functions for
> checking and returning the cached version of a file?
>
> Regards
>
> Thorsten


Think that PHP and smarty is not really that great a problem, lets look
at the database connection first !!!!

Pete
Thorsten Suckow-Homberg

2004-07-09, 4:02 pm

> Think that PHP and smarty is not really that great a problem, lets look
> at the database connection first !!!!


Hmmm...AFAIK smarty isn't responsible for handling db-connections ;)
Pete M

2004-07-09, 4:02 pm

What I meant was that in most scriipt processing whether using smarty or
not the thing that slows down page requests is the database...


Thorsten Suckow-Homberg wrote:

>
>
> Hmmm...AFAIK smarty isn't responsible for handling db-connections ;)

Boots

2004-07-09, 4:02 pm

--- Thorsten Suckow-Homberg <ts@siteartwork.de> wrote:
>
> Where is your problem?


Well, what is your setup like to support that many users? I'm sure you
are using a server farm, yes? What is your concurrency level? To me,
saying "enterprise" and throwing out a number without any other metrics
and then hypothesizing that a 60k file is too big just doesn't wash.

Respect,
xo boots
Marshall Sorenson

2004-07-09, 4:02 pm

This isn't directed at any one person, but please refrain from waging
personal battles on this mailing list. Have wasted time checking and
reading at least 5 or more e-mails on this thread that contain no real
useful information. If you have a problem with someone, reply to them
directly, and don't CC the list.

Thanks.

-Marshall


> -----Original Message-----
> From: boots [mailto:jayboots@yahoo.com]
> Sent: Friday, July 09, 2004 10:51 AM
> To: smarty-general@lists.php.net
> Subject: Re: [SMARTY] Smarty Light
>
>
> --- Thorsten Suckow-Homberg <ts@siteartwork.de> wrote:
>
> Well, what is your setup like to support that many users? I'm sure you
> are using a server farm, yes? What is your concurrency level? To me,
> saying "enterprise" and throwing out a number without any other metrics
> and then hypothesizing that a 60k file is too big just doesn't wash.
>
> Respect,
> xo boots
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Markku Niskanen

2004-07-09, 4:02 pm

On Fri, 9 Jul 2004 16:24:34 +0200, you wrote:

>Carrying around a 60 k file just for checking if a=20
>template is cached and then display it?


Just FYI: it is less than 30 K pure PHP code and if your are using
opcode caching the size does not matter much. The cached opcode
will not load from the disk, neither will it compile, it is simply run
(to check the caching, for a start, for instance)=20

Markku
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com