Detailed analysis of sample codes for performance comparison of golang, python, php, c++, c, java, and Nodejs

This article mainly introduces relevant information on the performance comparison of golang, python, php, c++, c, java, and Nodejs. Friends in need can refer to it When I was working in PHP/C++/Go/Py, I suddenly encountered I had an idea and wanted to make a simple comparison of the performance of the recent mainstream programming languages. As for how to compare, I still have to use the magical Fibonacci algorithm. Maybe it’s more commonly used or fun. Okay, talk is cheap, show me your code! Open your Mac, click on Clion and start coding! 1. Why is Go the first one? Because I am using it personally recently and I feel very good. package main import “fmt” func main(){ fmt.Println(fibonacci(34)) } func fibonacci(i int) int{ if(i<2){ return i; } return fibonacci(i-2) + fibonacci(i-1); } Let’s take a look with Go1.7 first: The code is as follows: qiangjian@ localhost:/works/learnCPP$ go version && time go build fib.go && time ./fibgo version go1.7.5 darwin/amd64 real 0m0.206suser 0m0.165ssys 0m0.059s real 0m0.052suser 0m0.045ssys 0m0.004s Then, look at 1.8: The code is as follows: qiangjian@localhost:/works/learnCPP$ go18 version && time go18 build fib.go && time ./fibgo version go1.8 darwin/amd64 real 0m0.204suser 0m0.153ssys 0m0.062s real 0m0.051suser 0m0.045ssys 0m0.003s I…

Godaddy space, PHP, two ways to send web forms by email

The Linux host used here is Godaddy. The Windows host should be similar, but I have not tried it. The first method is to use the mail() function that comes with PHP to send emails File organization , put the two files 123.html and send.php in the same directory 123.html Name Send email send.php > <?php $to = “[email protected]”; $subject = “Subject”; $message = “Hello! “.$_POST[“name”]. “,This is a simple email message.”; $from = “coder”; $headers = “From: $from”; if(mail($to,$subject, $message,$headers)) echo “Mail sent.”; else echo “Mail fail.”; ?> The second method is to use the phpmailer open source class File organization, put 123.html and send.php in the same directory, download phpmailer and name it phpmailer folder, and put it in same directory. Godaddy gives away a corporate email. Add an email account in the control panel to facilitate filling in the SMTP email account and password below. 123.html Name Send email send.php <?php header(‘Content-Type:text/html;Charset=utf-8’); require “phpmailer/class.phpmailer.php”; $mail = new PHPMailer; $mail->isSMTP(); // Set the email to use SMTP $mail->Host = ‘mail.site.com’; // Mail server address $mail->SMTPAuth = true; // Enable SMTP authentication $mail->CharSet = “UTF-8”; // Set email encoding $mail->setLanguage(‘zh_cn’); // Set error Chinese prompt $mail->Username = ‘[email protected]’; //…

(Transfer) Using Thrift0.9.1 to implement cross-language calls to Golang, Php, Python, and Java

(Transfer) Using Thrift0.9.1 to implement cross-language calls to Golang, Php, Python, and Java

Question introduction: What is Thrift? Where is the official website of Thrift? How to implement cross-language calls between Golang, Java, Python, and PHP through Thrift? 1. What is Thrift Thrift is a scalable cross-language service development software framework. It combines a powerful software stack with a code generation engine to build services. Thrift is fac Question introduction:What is Thrift?Where is the official website of Thrift? How to implement cross-language calls between Golang, Java, Python, and PHP through Thrift? 1. What is ThriftThrift is a scalable cross-language service development software framework. It combines a powerful software stack with a code generation engine to build services. Thrift was developed by Facebook. It opened source code in April 2007 and entered the Apache incubator in May 2008. Thrift was created to solve the problem of large data transmission and communication between systems in the Facebook system and the need for cross-platform features due to different language environments between systems. Therefore, thrift can support a variety of programming languages, such as: C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Javascript, Node.js, Smalltalk, and OCaml. (The current version 0.9.1 has started Supports golang language) to communicate between multiple different languages. Thrift can be…

Simple installation of nginx, php, mysql and golang under Ubuntu

I come from a PHP background, so naturally installing lnmp is a common skill. The previous method was lnmp installation package, such as Jun Ge’s lnmp1.0. With the updates of php and mysql, most one-click installations have problems with version aging and difficulty in updating. Therefore, I re-researched the installation of lnmp under Ubuntu and found that it is much simpler now. Let me record it. In addition, I am studying gola recently I come from a PHP background, so naturally installing lnmp is a common skill. The previous method was lnmp installation package, such as Jun Ge’s lnmp1.0. With the updates of php and mysql, most one-click installations have problems with version aging and difficulty in updating. Therefore, I re-researched the installation of lnmp under Ubuntu and found that it is much simpler now. Let me record it. In addition, I am learning golang recently, so installation under Ubuntu is naturally a necessary process. However, there are some mysteries in the installation of golang. Of course, it is not installed from source code. Nginx Stable/Development The package manager under Ubuntu is apt-get or dpkg. Conventional installation command apt-get install (note the permissions sudo apt-get install). Nginx is the most…

Golang, python, php, c++, c, java, Nodejs performance comparison

When I was working in PHP/C++/Go/Py, I suddenly had the idea to make a simple comparison of the performance of the recent mainstream programming languages. As for how to compare, I still had to use the magical Fibonacci algorithm. Maybe it’s more commonly used or fun. Okay, talk is cheap, show me your code! Open your Mac, click on Clion and start coding! 1. Why is Go the first one? Because I am using it personally recently and it feels very good. package main import “fmt” func main(){ fmt.Println(fibonacci(34)) } func fibonacci(i int) int{ if(i<2){ return i; } return fibonacci(i-2) + fibonacci(i-1); } Let’s take a look with Go1.7 first: The code is as follows: qiangjian@localhost:/works/learnCPP$ go version && time go build fib.go && time ./fib go version go1.7.5 darwin/amd64 real 0m0.206s user 0m0.165s sys 0m0.059s real 0m0.052s user 0m0.045s sys 0m0.004s Then, let’s take a look at 1.8: The code is as follows: qiangjian@localhost:/works/learnCPP$ go18 version && time go18 build fib.go && time ./fib go version go1.8 darwin/amd64 real 0m0.204s user 0m0.153s sys 0m0.062s real 0m0.051s user 0m0.045s sys 0m0.003s I can’t see the difference, but the official 1.8 has improved optimization by 20% in aspects such as GC…

JavaScript, PHP, Golang, Haskell, Elixir, which is the best programming language?

[CSDN Editor’s Note] Which language is the best programming language in your mind? Author | Michele Riva Translator | Crescent Moon Editor | Ouyang Shuli Produced by | CSDN (ID: CSDNnews) The following is the translation: Over the past few years, I’ve had the opportunity to try out a number of different programming languages ​​. I really enjoy learning different languages, methods and paradigms. I am a curious person and have always been fascinated by programming languages. Every programming language is different. In this article, we discuss the advantages and disadvantages of the following five programming languages. Javascript Haskell Go PHP Elixir Javascript Advantages Quick prototyping: You can use Javascript to quickly write some prototypes to verify your ideas. You can even use Node.js to build a proof of concept for the backend in minimal time. Flexibility: Javascript is growing in popularity, aided by the metaprogramming capabilities of ES6. However, even if you don’t use these functions, you can write some very common functions through Javascript and use it to write clients, servers, and even mobile applications (such as React Native, etc.). Community: The Javascript community is great. Every time you encounter a problem, you can find the answer through…

A small chestnut comparing the performance of golang, php, Node.js, Python and Rust

After seeing the comparison by netizen toozyxia (https://my.oschina.net/xiayongsheng/blog/4775399), I suddenly had the idea to add the comparison of Node.js golang: package main import ( “fmt” “os” “reflect” “runtime/pprof” “runtime/trace” “strconv” “time” “unsafe” ) type CalcCollection struct { } func (c *CalcCollection) V0() { arr := map[string]int64{} for i := int64(0); i <1000000; i++ { value := time.Now().Unix() key : = strconv.FormatInt(i, 10) + "_" + strconv.FormatInt(value, 10) arr[key] = value } } func (c *CalcCollection) V1() { nums := int64(1000000) arr := make(map[string]int64, nums) // key, put it outside the loop, you can reuse key := make([]byte, 0) for i := int64(0); i <nums; i++ { key = key [:0] value := time.Now().Unix() // Use appendInt instead to remove the overhead of converting []byte to string inside strconv key = strconv.AppendInt(key, i, 10) key = append(key, '_') key = strconv.AppendInt(key, value, 10) keyStr := string(key) arr[keyStr] = value } } func (c *CalcCollection) V2() { nums := int64(1000000) arr : = make(map[string]int64, nums) // Calculate the key length and apply to save []byte of all keys keyLen := int64(len(strconv.FormatInt(nums, 10)) + 1 + 10) totalLen := keyLen * nums key := make([]byte, totalLen) for i := int64(0); i <nums; i++…

pythonphp performance comparison_golang, python, php, c++, c, java performance comparison

Original title:Performance comparison of golang, python, php, c++, c, and java Golang, python, php, c+& in 2017 #43;, c, java, Nodejs performance comparison When I was working on PHP/C’/Go/Py, I had a sudden idea and wanted to make it mainstream recently. To make a simple comparison of the performance of programming languages ​​- as for how to compare – we still have to use the magical Fibonacci algorithm. Maybe it’s more commonly used or fun. Okay,talk is cheap, show me your code! Open Mac,Click on Clion and start coding! 1. Why is the first What about Go? Because I personally am using it recently and it feels very good. package main import “fmt” func main{ fmt.Println(fibonacci(34)) } func fibonacci(i int ) int{ if(i<2){ return i; } return fibonacci(i-2) + fibonacci(i-1); } Let’s take a look with Go1.7 first&#xff1a ; qiangjian@localhost:/works/learnCPP$ go version && time go build fib.go && time ./fib go version go1.7.5 darwin/amd64 real 0m0.206s user 0m0.165s sys 0m0.059s 5702887 real 0m0.052s user 0m0.045s sys 0m0.004s Then,Look at 1.8’s: qiangjian@localhost: /works/learnCPP$ go18 version && time go18 build fib.go && time ./fib go version go1.8 darwin/amd64 real 0m0.204s user 0m0.153s sys 0m0.062s 5702887 real 0m0.051s user 0m0.045s sys 0m0 .003s…

nodepython speed_c, golang, java, php, nodejs, python, pypy operation speed rough comparison

Throw out the result first, run java: end i:1000000000 count:499999999500000000 time:0.638 run C: end i:1000000000 count 499999999500000000 time:0.641424 run go: end i:1000000000 count:499999999500000000 time:1.277728 run pypy: end i:1000000000 count:499999999500000000 time:3.81583285332 run php end i:1000000000 count:499999999500000000 time:26.515455007553 run nodejs: end i:1000000000 count:499999999500000000 time:148.331 run python: ^Tend i:1000000000 count:499999999500000000 time:193.98550415 The above results have optimized the performance of golang and c. This result is beyond my expectations. 1. Neither c nor golang has started optimization. So the performance is only in the middle position. As a reference time 2, java, nodejs and pypy, all using JIT can operate very quickly. (It is related to the current test algorithm, but it is indeed obvious that repeated operations It is helpful) 3. There is no obvious difference in the operation speed of static language and dynamic language. The key point is whether there is JIT 4. Python is too slow. I have always known it. Python is slow, but I didn’t expect it to be slower than PHP in terms of calculations. 5. Nodejs is not as ideal as large number processing. If BigInt is not used, it is indeed faster than PHP, python, and pypy. ps: 1. Finally look forward to php8, because…

Simple installation of nginx, php, mysql and golang under Ubuntu

Simple installation of nginx, php, mysql and golang under Ubuntu

php tutorial|php manual Ubuntu, nginx, php, mysql, golang, php tutorial-php manual micro-commerce mall source code, vscode optimization code error, what is ubuntu called, udp protocol tomcat, sqlite3 Floating point numbers, there are centipede-like crawlers on the second floor, music website PHP source code, SEO optimization content, material Chinese website collection, discuz crack template installation lzw I am a PHP professional, naturally installing lnmp is a common skill. The previous method was lnmp installation package, such as Jun Ge’s lnmp1.0. With the updates of php and mysql, most one-click installations have problems with version aging and difficulty in updating. Therefore, I re-researched the installation of lnmp under Ubuntu and found that it is much simpler now. Let me record it. In addition, I have recently been studying the source code of the gola easy language module, does vscode support Android tablets, ubuntu USB disk path, tomcat configuration cer certificate, crawler data finance, php conference room management system, is e-commerce SEO free traffic, lzw short article source code, how to terminate vscode Run, ubuntu runs idea, tomcat closes and reports an error, focus on crawlers and distributed crawlers, php social networking site, Hailing District Wanci SEO consultation hotline, housekeeping website web source…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索