Some results from your script in new servers:
1) Red Hat Linux 9, Kernel 2.4.20, 128MB RAM, Pentium III 450MHz, Apache 2.0, PHP 4.2.2 as a module/filter, MySQL 3.23.56 (from a testing server at the University of Las Palmas de Gran Canaria). This is a very poor system.
Result: 265.83 seconds (1.33 seconds per call)
2) Red Hat Linux 8, Kernel 2.4.20, 1GB RAM, 4 Pentium Xeon CPU's at 2GHz, Apache 1.3.28, PHP 4.3.2 as a module, MySQL 4.0.13 (from a server at www.totalchoicehosting.com
). This is a very nice system, but it is shared by more than 250 web servers.
Result: 0.81 seconds (0,004 seconds per call)
Take into account that I have put the script in the same server being tested. You would get higher values if you tested them from any other server.
I have been monitoring the first, slow, system and I saw that the main problem was not the memory (though it was very small), but the CPU, wich was slow and just 1, having always a nearly 100% usage, more than 95% just for the Apache server (httpd), wich also handles PHP as a module/filter.
MySQL 4.0 also makes a very good job caching the SQL queries (all them were repeated). Take into account that MySQL 3.23 does not have query cache. I bet your MySQL is 3.x. Is it?
Another point is that Apache 2.0 is known to still have some problems, and the PHP module for it is a pre-alpha, very unstable one.
So, I guess that if you use latest stable versions of the software, avoiding Apache 2.0, you will improve a lot the performance of your Moodle server. I guess the most important part is upgrading to MySQL 4.0.14 (MySQL 4.0 was declared stable since 4.0.12).
Also, adding a PHP Accelerator program, sush as PHP Accelerator itself, Turck MMCache or Zend Accelerator would improve a lot the PHP performance (I think that this would reduce a lot the CPU usage). Getting some more memory (at least 512MB) and a faster CPU (the more you can) would help also.
For Windows 2000, you are just in the "recommended" ammount of RAM (256MB). Normally, to run any Micro$oft application, you need at least twice the "reccomended" ammount, and 4 times it to work really fine. The "minimum" is just ridiculous: you will see the desktop if you are lucky.
And... in my opinion, Linux is a much better platform to run Apache/PHP/MySQL than Windows, more reliable and with better performance using less resources.
By the way, no way to run your scripts (any of the 2) in my Windows XP with latests updates and Apache 1.3.24, PHP 4.3.1 as a module and MySQL NT 4.0.12.
The first one got this error:
Fatal error: Call to undefined function: socket_create() in c:\archivos de programa\apache group\apache\htdocs\moodletest.php on line 19"
The second one got this one:
"Connection nro: 1
Fatal error: Call to undefined function: set_socket_timeout() in c:\archivos de programa\apache group\apache\htdocs\moodletestwin.php on line 19"