views:

84

answers:

4

I mean PHP scripts on Apache are oriented for many users to use tham at the same time.

So will 1000 requests which came at the (relatively) same time be fully processed faster than C# .Net program performing algorithm 1000 times in while loop?

So we input same data, we perform same algorithm, which is written in the very same way (respecting language differences of course), output the same data (let us say saving it to file for them to be relatively equal)

Algorithm:

  • Open file (for each time different in size (from 1 to 500 mb) (FLV video files))
  • Read it in binary mode and trace while reading info about container and its components and such other stuff
  • Save traced info into file

Who will be faster on some 1000 times of performing algorithm or in 1000000, in which case (if it is possible) one will overrun another?

(on 2 Intel Xeon 2600MHz processors (each with 4 cores in it))

+2  A: 

Compiled programs (C#) will 99% of the time be faster than interpreted ones (PHP)

Jacob Relkin
Probably true, but whether a compiled app running tasks serially is faster than an interpreted app running the same tasks in parallel is really another question entirely.
Eric Petroelje
A: 

Your CPU won't be possible to handle 1000 PHP-Requests simultanly.

Telling you which is faster is not easy because a dualprocessor-system would be possible to run 2 PHP-Scripts at a time, but C# is JIT-Compiled and not interpreted like PHP, so it's hard to guess what's faster, measure the time ;)

Tobias P.
+1  A: 

Possibly.

If the C# program is doing the operation in a loop, it is only doing one at a time (unless you are using the new parallel extensions in .NET 4 that is).

With the PHP script it would be executing them in parallel, so it COULD be faster depending on how many CPUs you have and what exactly the script is doing (is it CPU bound, IO bound, etc.)

Eric Petroelje
Depends on usage of the Parallel extensions in .net 4. And overall, very much depends on the hard disk drive.
mcm69
A: 

Depends on implementation details but:

  1. PHP can be faster if you will use fastcgi + eaccelerator, and C# cannot process multiple requests
  2. C# will be absolutely faster if the implementation is the same and C# service uses the power of multiprocessing.
Everyz