SitePoint Sponsor

User Tag List

Page 4 of 6 FirstFirst 123456 LastLast
Results 76 to 100 of 130
  1. #76
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TomB View Post
    Was it the same 22kb file 1000 times? It's possible PHP does an internal cache so it doesn't need to do a full read again.
    It does. Even without APC cache the PHP engine only compiles bytecode for an include or require once per page request. The cache gives the engine a mechanism to store the bytecode for later page requests.

  2. #77
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TomB View Post
    Was it the same 22kb file 1000 times? It's possible PHP does an internal cache so it doesn't need to do a full read again.
    no, it was 1000 different files - each was a 750 line file of functions - I duplicated the files by loading the original, appending each function name with the iterator #, and saving it as a separately named file.
    aaron-fisher.com - PHP articles and more

  3. #78
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aamonkey View Post
    no, it was 1000 different files - each was a 750 line file of functions - I duplicated the files by loading the original, appending each function name with the iterator #, and saving it as a separately named file.
    .07 seconds doesn't sound like much until you multiply it by 1000 user requests / second - then you have a problem.

    Anything that takes over a hundredth of a second is worth looking into improving, but apc cache is the answer, not file collation.

  4. #79
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    930
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aamonkey View Post
    The single include ran about .07 seconds faster with no APC.
    But you didn't tell us the exact time each of the test took - then we would have a better idea about relative difference.

    It's possible PHP does an internal cache so it doesn't need to do a full read again.
    I don't think PHP caches separate include files but every modern OS does so in the test there was actually no physical disk access. The .07 seconds was spent seeking those files by the OS in the memory. If you measured the time on first page load after system restart I believe the difference would be huge.

  5. #80
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aamonkey View Post
    1) I included 1000 22kb files in a loop
    drop those to 256 bytes apiece and try it. Make each file a non exponant of two nearest their file size (21.25k) and try it.

  6. #81
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,883
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    Being the OP I thought it was time to clarify some issues:

    1. the code snippet I posted was for demonstration purposes only
    2. I am aware of bloated code especially for interpreted languages
    3. I am aware of numerous performance issues relating to including files
    4. would you believe I first programmed on punch cards early '70s last century
    5. my first personal computer was a Tandy TRS80 with 4K of memory
    6. 'have programmed using numerous languages including Assembler and used comments
    7. once studied and wrote a compiler using Prolog as part of my degree course
    8. using if(0) or if(1) is a simple way to toggle code snippets and monitor performance
    9. actual performance results are not immediate due to reasons beyond my control
    10. the site in question is used to test the latest evolving technologies
    11. maybe one day I will be happy to finish and optimise the site

    Meanwhile I get the general impression from the majority of posts in this thread that they are arguing over extremely small performance issues currently resolved by fast computers with an abundance of memory.

    I am more concerned tracing bottlenecks between original source code and the final user output.

    I am still looking for more suitable tools which will help in tracing bottlenecks.

    Here is my task for today - courtesy of Google Webmaster Tools:
    Last edited by John_Betong; Mar 9, 2011 at 19:10. Reason: remembered the trials and tribulations of Prolog :(
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  7. #82
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    drop those to 256 bytes apiece and try it. Make each file a non exponant of two nearest their file size (21.25k) and try it.
    Why?

    Quote Originally Posted by Lemon Juice View Post
    But you didn't tell us the exact time each of the test took - then we would have a better idea about relative difference.
    times were 2.12 seconds vs 2.19 seconds


    Quote Originally Posted by Lemon Juice View Post
    I don't think PHP caches separate include files but every modern OS does so in the test there was actually no physical disk access. The .07 seconds was spent seeking those files by the OS in the memory. If you measured the time on first page load after system restart I believe the difference would be huge.
    You may very well be correct, but if the os is caching the files, it's a moot point as the end result is still a negligible speed difference. As has been mentioned several times in this thread, apc fixes any of these discrepancies anyway.

    Also you guys are free to do your own tests and share your results
    aaron-fisher.com - PHP articles and more

  8. #83
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aamonkey View Post
    Why?
    Because that's probably smaller than a disk block size, of which EVERY file is rounded up to in size when stored or read from on a disk... Which is why a hundred 256 byte files take 50k on a 512 byte per sector disk (FAT filesystem for example), 100k on a 1024 byte per sector disk (some *nix, kinda rare), and 200k on a 2048 or even 4096 bytes per sector disk (like most modern NTFS or NFS3 multi-TB drives). Ever notice that some programs report "file size" and "file size on disk" -- and the latter is larger? Say hello to the smallest block size; which is the smallest a packet of data stored on a disk can be; most every filesystem out there does not support putting more than one file into a sector -- since the hardware doesn't support it either and you'd have to read, mask, and, and then write for those write operations.

    So for example on my machine (win7, NTFS, 4K blocks) a thousand quarter-k files would take two megabytes of disk space thanks to the block size (not counting the header blocks for sector tracking), while a 250k file would take 250k.

    Like in *nix -- touch a file to make a new empty one -- congrats a zero byte file is now consuming an entire sector; typically 512, 1024 or 2048 bytes... OR MORE.

  9. #84
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    930
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aamonkey View Post
    times were 2.12 seconds vs 2.19 seconds
    Ok, then the result was pretty good in your case
    You may very well be correct, but if the os is caching the files, it's a moot point as the end result is still a negligible speed difference.
    You are correct - I wasn't trying to argue that os caching is worse, although it may have sounded like that. Whatever mechanism does the caching it's good as long as it works.
    As has been mentioned several times in this thread, apc fixes any of these discrepancies anyway.

    Also you guys are free to do your own tests and share your results
    Actually, now I remember doing similar tests some 2-3 years ago on a few hosting servers I had access to and the conclusion was that the speed of include's was very dependent on the actual server. While separate includes suffered almost no penalty on one server they were pretty slow on another. The weird thing was that one server had eAccelerator installed and the includes were very slow. So there is no one answer to this since the speed depends on many factors and is very specific to a given setup.

  10. #85
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Been away for a day or so, but generally my point of view is that code should be clear, self documenting and readable. Given this, it amazes me that people don't do simple things like putting spaces around operators to make it far more readable (Something I think DS was against for some reason!), indenting and spacing things correctly (something I'm very fussy about) etc.

    Also, it's my view that micro-optimisation is useless. And while I don't use the comments like START BLOCK myself, I can see how some people find them useful and have no problem with them, including with all the ******* or ===== to make them stand out - perfect way to make it obvious where something begins and ends.

    I laugh at all the people who say you should use one style of echo, dots instead of commas, different quote styles etc because it is nanoseconds faster - completely silly given the grand scheme of things. Readability is THE most important thing in coding as far as I'm concerned.

  11. #86
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    perfect way to make it obvious where something begins and ends.
    The question appears again: Why isn't it obvious in the first place? Or, why isn't it obvious enough without
    <?php /* ===================== START BLOCK ======================== */ ?>

    Or

    /************************************Header styles**********************************/
    (esp when followed by a bunch of stuff with "header" in the name)

    The other question: WHO isn't it obvious to?

  12. #87
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    <div> doesn't really stand out of code that much - especially surrounded by lots of other divs, but that comment certainly does!

    I do use that kind of thing for grouping styles (with 1 star though) eg:

    /* Header */

    some styles

    /* Content */

    Although it's obvious what styles follow it, it makes it a hell of a lot easier when scrolling around a css document to see the groups and find the one you are looking for.

  13. #88
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    Given this, it amazes me that people don't do simple things like putting spaces around operators to make it far more readable (Something I think DS was against for some reason!)
    Actually I find spaces around operators LESS clear because it then looks like a bunch of different operations instead of one... to me spaces are for around binary operators (and,or,xor,not) and not mathematical /syntatic/comparison ones. Basically I find:

    $x=$x+1; clearer than $x = $x + 1;

    Maybe it's just because symbols stand out like a sore thumb next to alpha for me -- maybe because I never saw ANYONE format code with all those extra spaces until about seven years ago... (which after 33 years of programming...)

    But really that's a minor legibility issue and so long as the entire codebase is formatted CONSISTENTLY (pick a method and stick with it) I'm not THAT picky.

    But in terms of DIV, it does stand out if you put your block level containers on their own lines and use the tab key -- the only reason for those type of giant comments with the endless strings of the same character is if you aren't indenting your code properly.

    Is it that hard to look at the left edge of the screen and see the fist-in-the-face indent?

  14. #89
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    <div> doesn't really stand out of code that much - especially surrounded by lots of other divs, but that comment certainly does!

    I do use that kind of thing for grouping styles (with 1 star though) eg:

    /* Header */

    some styles

    /* Content */

    Although it's obvious what styles follow it, it makes it a hell of a lot easier when scrolling around a css document to see the groups and find the one you are looking for.
    ^ this

    It's not an issue of how well the code is written, it's an issue of quickly being able to scroll through a giant file and quickly find a section that needs attention. This isn't a problem in a 200 line file, but a 2000+ line file (regardless of if your indenting/spacing is perfect) things are still hard to find quickly.
    aaron-fisher.com - PHP articles and more

  15. #90
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    Actually I find spaces around operators LESS clear because it then looks like a bunch of different operations instead of one... to me spaces are for around binary operators (and,or,xor,not) and not mathematical /syntatic/comparison ones. Basically I find:

    $x=$x+1; clearer than $x = $x + 1;
    Really? I'm amazed. When I look at variables, operators, strings etc all cramped together into 1 bunch of characters, I find it hard to pick out out from the other. It all just looks like 'a bunch of characters' at a quick glance. Spaced out it's a hell of a lot easier to see the separation between different types of characters - eg variables, lines, literal strings etc.

    The days of trying to squeeze every byte out of the code to save space are gone. No need to be stuck in the old ways when there is a much easier way available now!

    This is also a symptom of something I see a lot recently, that smaller / compact code means more efficient or neater code. It just isn't the case!

    Quote Originally Posted by deathshadow60 View Post
    But in terms of DIV, it does stand out if you put your block level containers on their own lines and use the tab key -- the only reason for those type of giant comments with the endless strings of the same character is if you aren't indenting your code properly.

    Is it that hard to look at the left edge of the screen and see the fist-in-the-face indent?
    I do indent properly, as I said above, and everything is on its own line as you say, but I wasn't talking about matching one with the other - more that if you have some nested divs with some siblings around it etc, it can be harder to remember which one is the 'block' the comment refers to (block seems pretty meaningless as a description, but then out of context you have no idea what the page function is so could be perfectly meaningful in context).

    Even with the indenting, if the opening and closing are several screens apart, it can be harder to match them - although my editor highlights them anyway so not so much of a problem. I use a 2 space indent (tabs annoy the hell out of me) so everything doesn't go shooting off the right hand side of the screen once you've nested more than 3 levels deep.

  16. #91
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    I do use that kind of thing for grouping styles (with 1 star though) eg:
    I also do that kind of grouping, for when it's stuff that doesn't have any particular order in the HTML.

    But I find the whole /**************************ZOMG LOGOS***************************************/ thing a bit much. : )

  17. #92
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I dunno, I can see how it makes sections very obvious - I have no particular problem with it, even if I don't do it myself!

  18. #93
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ...and it's certainly not a 'FAIL HARD'!

  19. #94
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    I use a 2 space indent (tabs annoy the hell out of me) so everything doesn't go shooting off the right hand side of the screen once you've nested more than 3 levels deep.
    NOOOOOO!!! That's double the characters for every indented line you are going to crash the internet!

    ....No, but seriously - I thought most (if not all) code editors/IDEs allow you to set the tab indent?
    aaron-fisher.com - PHP articles and more

  20. #95
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,883
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    Has anyone taken the trouble to look at the source code generated for the home page of the relevant site?

    According to the profiler the home page is generated is '0.0702secs'. Also numerous images are loaded using techniques gleaned from Speed Tips: Use Multiple SubDomains

    The overall effect is to load the crappy, inefficient source code, javascript and images, in less than 2 seconds.

    Mission accomplished
    Last edited by John_Betong; Mar 10, 2011 at 09:20. Reason: forgot to mention the javascript
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  21. #96
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aamonkey View Post
    NOOOOOO!!! That's double the characters for every indented line you are going to crash the internet!

    ....No, but seriously - I thought most (if not all) code editors/IDEs allow you to set the tab indent?
    Yeh, but then when someone uses a different one it can screw up the formatting in certain places.

    Tabs were invented for layout out tabular data - ie, indenting several values to the same column no matter what the length of the previous column was. It was never supposed to be used for indenting.

    The biggest risk is that if you allow tabs, you could have a mixture of tabs and spaces - which opens a whole can of worms in itself!

  22. #97
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    Yeh, but then when someone uses a different one it can screw up the formatting in certain places.

    Tabs were invented for layout out tabular data - ie, indenting several values to the same column no matter what the length of the previous column was. It was never supposed to be used for indenting.

    The biggest risk is that if you allow tabs, you could have a mixture of tabs and spaces - which opens a whole can of worms in itself!
    Well I guess that is a whole other debate - we probably don't need another topic change in this thread so I will

    Cheers
    aaron-fisher.com - PHP articles and more

  23. #98
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aamonkey View Post
    NOOOOOO!!! That's double the characters for every indented line you are going to crash the internet!

    ....No, but seriously - I thought most (if not all) code editors/IDEs allow you to set the tab indent?
    All the editors I use let you set the tab stop... I typically set it for two, but using tabs lets each person view it indented however much or how little they like.

    Though really spaces or tabs should make no difference as any editor worth using typically has a 'convert spaces to tabs' and 'convert tabs to spaces' and the really good ones have "convert leading spaces only to tabs" so switching back and forth between whatever you like and what someone else likes is easy. (I'll often hit the "convert to spaces" before posting code online if it's got a lot of indenting)

    Though some editors don't do block indent/de-indent selection on spaces. (gEdit for example) many don't care what type of leading tabs are there when doing that (crimson, edit+, notepad++) -- though I'm often surprised how many programmers don't even know you can do block indent/de-indent.

    Mostly I just find spaces instead of tabs annoying when making small edits or when posting code online - which is why I usually convert to tabs before editing and only convert to spaces for online posting of snippets.

    Oh, and tabs were NOT invented for "tables" -- they were invented for indenting content and even for indenting the start of a paragraph; if you go back to typewritten age at least where you had mechanical adjustable tab-stops.

    http://dictionary.reference.com/browse/tab

    7. Also called tabulator. a stop on a typewriter, actuated by a key, that moves the carriage, typing element, etc., a predetermined number of spaces, used for typing material in columns, for fixed indentations, etc.

    8. a programmed command on a computer, actuated by a key, that moves the cursor or printhead a predetermined number of spaces, used for keying material in columns, for fixed indentations, etc.
    While tabulation is part of it's function, it's also for fixed indentations... like cleanly written code. In fact indent blocks could be considered tabular data since you are creating column indentations that line-up; since a table is NOT necessarily a grid.

    http://dictionary.reference.com/browse/table

    an arrangement of words, numbers, or signs, or combinations of them, as in parallel columns, to exhibit a set of facts or relations in a definite, compact, and comprehensive form; a synopsis or scheme.
    Notice Synopsis or scheme -- like a "table of contents"? Those are indented on only one side. Parallel even though they can contain each-other.

  24. #99
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    I'm just glad PHP doesn't care about your tabbing. That drove me insane when I was using Python.

  25. #100
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Michael Morris View Post
    I'm just glad PHP doesn't care about your tabbing. That drove me insane when I was using Python.
    That too.

    I'm such a stickler for formatting you'd think I'd be a huge fan of python -- but the rest of that language which drove me nuts... (It's almost as needlessly cryptic as Ruby -- BAD when you have languages now that make C look verbose)

    Well, that and I like to SEE the close on an element as an actual element and not JUST a de-indent. Gimme my RET, my LABEL, my }, my END; anyday over "I hit backspace"

    See why I like 1TBS over Allman -- I like my close to line up with the statement being closed, not just the opening bracket.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •