Nonsense not to say, direct (the first one is the script written by Python, the second and third is the shell):
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/54/93/wKiom1SGpk6Ttl_MAAVPK2KJQoE175.jpg "title=" Python and shell efficiency comparison. png "alt=" wkiom1sgpk6ttl_maavpk2kjqoe175.jpg "/>
The file is a nginx log file, a total of 5.83 million lines, and then the number of statistics of each IP occurrence, the execution time of each script as shown above.
The test environment is: CentOS 6.5, Quad core cpu,8g memory.
Here is the Python script
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/54/93/wKiom1SGpyWTNsivAADzGXo_iNs410.jpg "title=" Test.jpg "alt=" Wkiom1sgpywtnsivaadzgxo_ins410.jpg "/>
The result: the fastest self-increment in a single-core case, the Python script followed by the combination of the awk and sort commands, guessing that awk is written in C + +, and that Python interprets execution, awk | The combination of sort |uniq, estimating which cohesion is not good and the least efficient.
Python's multithreading is not tested and later tested, then the results are sent up.
PS: I do not know the Python program is inefficient or so, if there is a better way of writing, tell Me,please.
Python, shell scripts perform the same operation, which takes time efficiency comparisons