| Author |
Question about speed of 3 functions |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
For my cms I'm using an xml database to hold all the info for 1) global variables and 2) each individual page.
The question is:
When a user edits a page though the interface, the code will edit the xml to put in the right values for everything. When you want to see a page, the page opens up the template for the website, opens up the xml file with the info, and fills it in.
So the question actually is:
Should I save the xml file with the info and hard-code each page for faster loading (this way through the interface the xml is changed and the page re-hardcoded again), or should I just save the xml file and let each page open up the xml each time it's opened up to get its variables?
Advantage of hard-coding the pages based on xml template:
Faster page loading/less server strain
Advantage of using xml each time:
If someone wants to personally change some code, they can change the xml. If the other method is used if he changes the html only, when the interface is used the xml will override previous changes he has made manually to html.
So really, it boils down to, is opening up a simpleXML file much more resource intensive than using include(). If it's not, then I might as well use the xml opening each time, because it's not worse than include and it ensures no one will override data.
If I'm confusing, I can post a code snippet.
Also, is fopen slow? As in slower than include?
Wisdom spared is wisdom squared.
Edited by ranma on 20-07-09 18:49 |
|
| Author |
RE: Question about speed of 3 functions |
ynori7
Future Emperor of Earth

Posts: 1481
Location: #valhalla
Joined: 08.10.07 Rank: Diabolical |
|
Alright, that wasn't very clear. Let me reword it and see if I understand correctly. In both cases you want to use XML files to store your global variables.
Case 1: The pages all have the values programmed into them, and these values get updated from the XML all at once when you tell them to.
Case 2: The pages each access the XML file every time they're loaded for real-time updates.
If that's what you meant, I'd go with case 1. It's only necessary to update the files when a change has been made. It's more efficient.
EDIT:typo
Edited by ynori7 on 20-07-09 20:17 |
|
| Author |
RE: Question about speed of 3 functions |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
Yup! That's what I meant.
However, that means if someone goes into the html manually and changes it, next time the interface is used the xml will override his handmade changes.
Would you say case 1 is much more efficient ? Or would case 2 not be too bad.
Wisdom spared is wisdom squared. |
|
| Author |
RE: Question about speed of 3 functions |
ynori7
Future Emperor of Earth

Posts: 1481
Location: #valhalla
Joined: 08.10.07 Rank: Diabolical |
|
ranma wrote:
Would you say case 1 is much more efficient  ? Or would case 2 not be too bad.
Maybe, maybe not. But case 2 is needlessly inefficient. There's not much gain from reloading the file every time you access a page. In fact, I think if you have a large number of people accessing your site, it could place extra strain on the server. It depends on how much data is being read from the file.
|
|
| Author |
RE: Question about speed of 3 functions |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
Is it worse than an include though?
And I mean loading no more than around 20 KB of data.
Edit: Well, really it should be no more strain than running a query on a db, since xml is also used as flatfile databases.
Wisdom spared is wisdom squared.
Edited by ranma on 20-07-09 21:36 |
|
| Author |
RE: Question about speed of 3 functions |
c4p_sl0ck
Member

Posts: 380
Location: Sweden
Joined: 17.09.06 Rank: God |
|
If you can open the XML file as little as possible I think it would take some strain off the server.
If I got the whole thing correctly, the problem is that if a user decides to edit the HTML instead of XML, it will be overridden either always or only when you tell it too? Then I think it is better to only override it when you want it to, and clearly state that it is recommended to change the XML instead of HTML.

 |
|
| Author |
RE: Question about speed of 3 functions |
ynori7
Future Emperor of Earth

Posts: 1481
Location: #valhalla
Joined: 08.10.07 Rank: Diabolical |
|
|
ranma wrote:
Edit: Well, really it should be no more strain than running a query on a db, since xml is also used as flatfile databases.
SQL is has a lot of optimizations built into it.
|
|
| Author |
RE: Question about speed of 3 functions |
p4plus2
Member
Posts: 167
Location:
Joined: 31.03.08 Rank: God |
|
|
ranma wrote:
Is it worse than an include though?
And I mean loading no more than around 20 KB of data.
Edit: Well, really it should be no more strain than running a query on a db, since xml is also used as flatfile databases.
Why not test it out? Benchmark each about a thousand times and average it out... Yeah this is extra work but it will get you the most precise answer. My assumption is that SQL will be the victor(pgSQL if I had to pick which type of SQL). I would link you to benchmarks online, however those are often misleading due to different configurations.
"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera
"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine |
|
| Author |
RE: Question about speed of 3 functions |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
Thanks everyone.
P4plus, I'll do that.
Wisdom spared is wisdom squared. |
|