Jasig/phpCAS — Issue #5: Investigate a possible switch to the Apache 2.0 License as the rest of Jasig has done
Author: adamfranco
Created: 2011-10-26 20:11:17+00:00
State: open

*[Migrated from PHPCAS-131](https://issues.jasig.org/browse/PHPCAS-131)*

Description
=========

I guess we should look into making the switch with the 1.3.0 version. Since all of the code is BSD it should not be a big issue. We just have to be carefull with all the different headers and files.

https://wiki.jasig.org/display/LIC/Home

I however don't like adding a full text to all source files. I would really like to place doxygen comments like @license in all code files referring to the external license file. Adding the full text to compiled language makes sense but in an interpreted language it's just a lot of overhead during runtime if you bloat all the source files.

Adam Franco added a comment - 26/Sep/11 10:54 PM
------------------------------------------------

When using APC or another opcode cache, parsing time becomes basically irrelevant since files are only even opened and read when changed. As well, according to this post and a few others like it indicate that comment parsing shouldn't be an issue.

That said, I didn't want to go on just hearsay, so I decided to run a few tests to find out how stripping out comments and white-space affected execution time:

[afranco@maple phpcas]$ # A command to time execution
[afranco@maple phpcas]$ cat run_1000
#!/bin/bash
i=0;
while [ $i -lt 1000 ]; do
php $1;
let i=$i+1;
done;
[afranco@maple phpcas]$
[afranco@maple phpcas]$ # First a test with an empty script.
[afranco@maple phpcas]$ echo ' empty.php
[afranco@maple phpcas]$ time ./run_1000 empty.php

real	0m9.404s
user	0m5.671s
sys	0m2.700s
[afranco@maple phpcas]$
[afranco@maple phpcas]$ git reset --hard
HEAD is now at 0926ab8 NOJIRA fix errors in examples
[afranco@maple phpcas]$ # Characters in phpCAS
[afranco@maple phpcas]$ find source -name "*.php" -exec cat {} \; | wc -c
305774
[afranco@maple phpcas]$ time ./run_1000 source/CAS.php

real	0m18.341s
user	0m13.387s
sys	0m3.764s
[afranco@maple phpcas]$
[afranco@maple phpcas]$ # Strip comments and whitespace
[afranco@maple phpcas]$ find source -name "*.php" -exec sh -c 'php -w {} > {}.tmp; mv {}.tmp {}' \;
[afranco@maple phpcas]$ # Characters in phpCAS after stripping whitespace and comments
[afranco@maple phpcas]$ find source -name "*.php" -exec cat {} \; | wc -c
123311
[afranco@maple phpcas]$ time ./run_1000 source/CAS.php

real	0m17.358s
user	0m12.474s
sys	0m3.709s
[afranco@maple phpcas]$
[afranco@maple phpcas]$ git reset --hard
HEAD is now at 0926ab8 NOJIRA fix errors in examples
[afranco@maple phpcas]$

So, shrinking the file-size by 60% resulted in a 7% change in execution time. I don't think this is significant enough to change our general commenting practices (the readability cost wouldn't be worth it), but it probably doesn't make sense to put a full 135-line license in each file. The short version below would probably be sufficient in the header and shouldn't change the execution time much on systems without an opcode cache.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.