summaryrefslogtreecommitdiff
path: root/documentation/bubblesort.html
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-07 15:39:09 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-07 15:39:09 +0100
commit8f7e2f6788ea91c6e70cb1e5afebd66c8acedcdb (patch)
tree52245b77a295ec0da04cfbb8d9190963ede91e04 /documentation/bubblesort.html
parenta4a5f7766e906f35a9c46c4af719c24a10c4ef99 (diff)
update to bubblesort example
Diffstat (limited to 'documentation/bubblesort.html')
-rw-r--r--documentation/bubblesort.html21
1 files changed, 19 insertions, 2 deletions
diff --git a/documentation/bubblesort.html b/documentation/bubblesort.html
index 824057b..7c1f2bc 100644
--- a/documentation/bubblesort.html
+++ b/documentation/bubblesort.html
@@ -4,7 +4,7 @@
with a very simple extension: bubblesort.
</p>
<p>
- Bubblesort is a very inefficient sorting algorithm that is never used in
+ Bubblesort is an extremely inefficient sorting algorithm that is never used in
real world software - but that is often used in universities to demonstrate
algorithms. We will show you an implementation of this algorithm in PHP
and in C++ - and see how much faster the C++ code is.
@@ -158,8 +158,25 @@ $scripted = microtime(true);
// show the results
echo("Native: ".($native - $start)." seconds\n");
-echo("Scripted: ".($scriped - $native)." seconds\n");
+echo("Scripted: ".($scripted - $native)." seconds\n");
?&gt;
</code></pre>
</p>
+<p>
+ This is the output on from a regular laptop. You can see that the native C++
+ implementation is about ten times as fast as the PHP implementation.
+<p>
+<pre>
+Native: 0.79793095588684 seconds
+Scripted: 8.9202060699463 seconds
+</pre>
+</p>
+<h2>Summary</h2>
+<p>
+ C++ is faster - much faster - than code in PHP, even for very simple scripts.
+ The source code for an extension written in C++ is almost identical to the
+ source of the same algorithm in PHP. Every programmer that is capable of
+ writing a PHP script, could just as well write it in C++ and get a ten times
+ better performance.
+</p>