简体   繁体   中英

Will PHP script running on top of Apache be faster than C# stand alone program doing same thing (same counting algorithm)?

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))

编译程序(C#)的速度将比解释程序(PHP)快99%

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM