Follow us on Twitter!
Ideas are far more powerful than guns.
Saturday, April 19, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 23
Guests Online: 20
Members Online: 3

Registered Members: 82838
Newest Member: w1zarrd
Latest Articles
View Thread

HellBound Hackers | Computer General | Webmasters Lounge

Author

Question about speed of 3 functions

ranma
Member



Posts: 273
Location: Behind a sphere
Joined: 27.08.05
Rank:
Active User
Posted on 20-07-09 18:32
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
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 20-07-09 20:16
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


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg


Edited by ynori7 on 20-07-09 20:17
ynori7 http://halls-of-valhalla.org
Author

RE: Question about speed of 3 functions

ranma
Member



Posts: 273
Location: Behind a sphere
Joined: 27.08.05
Rank:
Active User
Posted on 20-07-09 20:36
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 efficientWink? Or would case 2 not be too bad.


Wisdom spared is wisdom squared.
Author

RE: Question about speed of 3 functions

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 20-07-09 21:15
ranma wrote:
Would you say case 1 is much more efficientWink? 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.


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Question about speed of 3 functions

ranma
Member



Posts: 273
Location: Behind a sphere
Joined: 27.08.05
Rank:
Active User
Posted on 20-07-09 21:34
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


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-07-09 22:39
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
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 20-07-09 23:15
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.


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Question about speed of 3 functions

p4plus2
Member

Your avatar

Posts: 167
Location:
Joined: 31.03.08
Rank:
Newbie
Posted on 21-07-09 00:44
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
p4plus2@hotmail.com
Author

RE: Question about speed of 3 functions

ranma
Member



Posts: 273
Location: Behind a sphere
Joined: 27.08.05
Rank:
Active User
Posted on 21-07-09 18:31
Thanks everyone.
P4plus, I'll do that.


Wisdom spared is wisdom squared.