Speed of PHP vs JavaScript?

后端 未结 3 1736
执念已碎
执念已碎 2020-12-10 02:37

I am writing a script to tokenize file contents. I\'ve written a tokenizer in JavaScript, but it gets pretty slow with large files (5+ seconds). Since I\'m retrieving the fi

相关标签:
3条回答
  • 2020-12-10 02:38

    I just converted a script from PHP to Javascript and I have greatly increased performance.

    Javascript seems much faster in mathematical calculations. I have personally witnessed the performance improvement, my PHP procedure in some cases also employed a few seconds of running, while the same procedure written in javascript takes at most a few milliseconds.

    Although Javascript to be known as client-side language I run my code on the server side thanks to Node.js

    0 讨论(0)
  • 2020-12-10 02:39

    Well, like you alluded, JavaScript is executed on the client side, so it would depend on the client. For example, a client on an iPAD wouldn't be able to run those Quake3 HTML5s as smoothly as a client running on a gaming machine. PHP on the other hand runs on the server.

    In general, JS is faster considerably than PHP though (on the same hardware);

    Here are some [hard figures][1] of tests between the two, to back up my assertion. [JS (query) vs PHP][2] Performance.

    [1]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/php.html [2]: jQuery vs. PHP - Performance Comparison

    0 讨论(0)
  • 2020-12-10 03:02

    Its worth saying that another consideration for using PHP is the ability to cache server side. I'm looking at this considering if I should move some of the functions from JS to PHP because if I then cache the files server side there is no further calculations involved at all! I know this ticket is old but this may be another consideration for future readers.

    0 讨论(0)
提交回复
热议问题