From 8f7e2f6788ea91c6e70cb1e5afebd66c8acedcdb Mon Sep 17 00:00:00 2001
From: Emiel Bruijntjes
- 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 ++ +
+ 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