开发者

Benchmarks of scripting languages doing the same task?

开发者 https://www.devze.com 2023-01-12 20:27 出处:网络
Does anyone know where I could find reviews or reports on tasks that people implemented in two or more scripting languages to see which was more suited to a specific job? I want to know which language

Does anyone know where I could find reviews or reports on tasks that people implemented in two or more scripting languages to see which was more suited to a specific job? I want to know which languages are best suited to which types of operation so that I can make the most of them.

"Types of operation" could be sockets, the f开发者_StackOverflow社区ile system, logic evaluation, regex, or drawing.

I'm mostly interested in Python, PHP, Perl, and Ruby.


There's the programming language shootout: http://shootout.alioth.debian.org/ Although it may not measure enough of the things you're looking for.

However, benchmarks almost certainly won't tell you anything useful about high level ideas of the sort you listed. For those things, the performance (as in speed of execution) has almost nothing to do with what language the code is written in (at least for the set of languages you listed, all of which have quite similar execution models), and almost everything to do with how the code is structured.

If you want to be able to choose one of the languages you listed (for a particular task) based on something relevant, the questions you should be asking are:

  • What restrictions are there given the platform you want to run on? All of the languages you listed have large runtime systems -- interpreters -- which means they may have heavy deployment costs if you want to use them on systems on which they are not already installed. Having said that, Python at least has 'py2exe' and 'py2app' which can be used to make deployable executables of your application for Windows or Mac -- there may well be something similar for the other languages you listed.
  • What relevant functionality is provided in the standard library for the language? (in this case, all the listed languages have very large, useful standard libraries).
  • What relevant functionality is available in external libraries that you could use?
  • How comfortable are you using the language?

Finally, if execution speed really is very important in your application, and if you find that you can't achieve the speed you need even with an appropriate choice of architecture in your chosen language, then you can identify the bottleneck and re-implement that in a compiled language, providing an interface back to the scripting language so it can be integrated into the application. All of the languages you listed support such native-code extensions.


I would look at the programming tasks on Rosetta code.

You should be able to find idiomatic code for the languages you're interested in, and then benchmark under whatever usage conditions you expect. This frees you from having to write the tests yourself, and you often see interesting approaches for the different languages.


The best thing to do would be to create your own benchmarks for the specific tasks you are interested in. Pick languages that you like working in and then write benchmarks for the system you will be using and the task you will be performing. If you are very concerned about speed I would also recommend looking at the individual operations and how to optimize them in each of the languages (examples: argument order, memory usage...)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号