From 8f7e2f6788ea91c6e70cb1e5afebd66c8acedcdb Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Fri, 7 Mar 2014 15:39:09 +0100 Subject: update to bubblesort example --- documentation/bubblesort.html | 21 +++++++++++++++++++-- 1 file 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.

- 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"); ?>

+

+ 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. +

+

+Native:   0.79793095588684 seconds
+Scripted: 8.9202060699463 seconds
+
+

+

Summary

+

+ 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. +

-- cgit v1.2.3