I read that when the PHP lexer parses the php and encounters a doccomment, that it stores the contents of that comments as metadata. So I would assume this might have a slight overhead compared to using regular comments in non-doccomment format?
Regular comment...
<?php
/*
some text
/*
// more comments
?>
doccomment...
<?php
/**
* @author Kenneth Davis
* @copyright 2011
* @filename Exception.class.php
*/
?>
As others have mentioned, the difference is so small that it doesn't matter. But to answer your question, there is a difference in runtimes. To test this, I've generated two php files, each with 50000 classes, and each weighing in at exactly 4288896 bytes.
Here's the template I used for the docblock version:
/**
* My Docblock
*/
class MyClass%s {}
and here's the version with no true docblock (without the two * at the
beginning, ReflectionClass::getDocComment()
did not find the comment):
/*-
* My Docblock
*/
class MyClass%s {}
The full script to generate the php files is here: https://gist.github.com/1268179
To see any noticable difference in time, I had to run each through php 10 times, like so:
time yes docblock.php | head -n 10 | xargs -n 1 php
Here's the outcome:
with docblocks:
xargs -n 1 php 2.22s user 0.63s system 99% cpu 2.873 total
without docblocks:
xargs -n 1 php 2.16s user 0.63s system 99% cpu 2.813 total
Running this several times, seemed to yield consistent faster (barely) times for the no docblock version.
To sum it up, that's about 0.00012 milliseconds per docblock that php keeps track of (if I did my math right there).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With