473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Why do templates improve performance?

Hello

I'm no PHP expert, and I'm reading "Building scalable web sites". In
the tips section, the author mentions using templates to speed things
up. I was wondering how the template engines manage PHP pages that
contain calls to MySQL: In our application, the data returned is
different for most users, so the resulting page has different
contents. So why do templates (and opcode cache) improve performance?

Thank you.
Aug 25 '08 #1
5 1493
Hi,

Gilles Ganault wrote:
I'm no PHP expert, and I'm reading "Building scalable web sites". In
the tips section, the author mentions using templates to speed things
up.
Generally spoken, this is wrong. Templates _might_ speed things up if
they manage to take a better approach to caching than your application
does otherwise itself.
I was wondering how the template engines manage PHP pages that
contain calls to MySQL: In our application, the data returned is
different for most users, so the resulting page has different
contents. So why do templates (and opcode cache) improve performance?
Because they encourage to split the displayed parts up into logical
entities (say: a catalogue entry) and bring abilities to cache those
fragments that seldom change.

Opcode cache is a completely different beast. It saves the burden of
text (i.e. PHP code) parsing, and may also do some JIT optimizations.

-hwh
Aug 25 '08 #2
On Mon, 25 Aug 2008 12:32:07 +0200, Hans-Werner Hilse <hi***@web.de>
wrote:
>Because they encourage to split the displayed parts up into logical
entities (say: a catalogue entry) and bring abilities to cache those
fragments that seldom change.
Ah OK. So I should split the static parts and the dynamic parts that
make up a page.
>Opcode cache is a completely different beast. It saves the burden of
text (i.e. PHP code) parsing, and may also do some JIT optimizations.
Thanks.
Aug 25 '08 #3
Gilles Ganault <no****@nospam.comwrites:
So why do templates (and opcode cache) improve performance?
Templates improve *programmer* performance by cleanly separating logic
from presentation.

As for improving *program* performance? Not so much. :-)

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Aug 25 '08 #4
Gilles Ganault wrote:
Hello

I'm no PHP expert, and I'm reading "Building scalable web sites". In
the tips section, the author mentions using templates to speed things
up. I was wondering how the template engines manage PHP pages that
contain calls to MySQL: In our application, the data returned is
different for most users, so the resulting page has different
contents. So why do templates (and opcode cache) improve performance?

Thank you.
Someone argued templates improve "development speed" by separating
logic from presentation. The templating systems all make that
arugment. Well, maybe. Separating logic from content is a worthy design
goal. But you don't necessarily need a templating engine to do that.
file_get_contents() works fine for me.

I spent a few weeks playing with SmartyTemplate once (one of the more
popular templating systems) and I didn't think it was worth the hassle.
the *.tpl files Smarty employs are a pain to work with (difficult to
debug) and it just doesn't buy you anything you couldn't do yourself
with good abstract code design and file_get_contents() for retrieving
html fragments.

Templating systems are great for Java Servlets: you can change html
with a text editor, without recompiling the code. But for interpreted
languages you don't need that anyway.
--
cut the board three times and it's still too short
Aug 25 '08 #5
On Mon, 25 Aug 2008 13:06:14 -0600, sliverdigger
<sl**********@closenuf.netwrote:
>Someone argued templates improve "development speed" by separating
logic from presentation. The templating systems all make that
arugment. Well, maybe. Separating logic from content is a worthy design
goal. But you don't necessarily need a templating engine to do that.
file_get_contents() works fine for me.
Thanks for the input.
Aug 26 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andre | last post by:
Hi, I've built a math library that does some matrix multiplications and other linear algebric functions. I read some place about generics or class templates and I was wondering if this will help...
7
by: Jon Slaughter | last post by:
#pragma once #include <vector> class empty_class { }; template <int _I, int _J, class _element, class _property> class RDES_T {
9
by: Peng Jian | last post by:
I have a function that is called very very often. Can I improve its efficiency by declaring its local variables to be static?
11
by: Elpoca | last post by:
Hi: What rules govern the inlining of templated functions and templated class methods? It has always been my understanding that both templated functions and templated class methods were...
14
by: projecktzero | last post by:
For some of the web programming I've done in Python, I've used htmltmpl. I had some experience with it in Perl, and found a Python version. http://htmltmpl.sourceforge.net/ I like that...
25
by: Ted | last post by:
I'm putting the posts that follow here (hopefully they will follow here!) because they were rejected in comp.lang.c++.moderated. It behooves anyone reading them to first read the the thread of the...
3
by: Johs | last post by:
I have read that when you are using templates you are making generic programs. But I don't see whats so generic about templates. You can make generic programs without templates through the use of...
10
by: colin | last post by:
Hi, I profile my code and find its spending a lot of time doing implicit conversions from similar structures. the conversions are mainly things like this class Point { implicit conversion...
2
by: sdanda | last post by:
Hi , Do you have any idea how to improve my java class performance while selecting and inserting data into DB using JDBC Connectivity ......... This has to work for more than 8,00,000...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.