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…
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…
C/C++, Java, Go, Python summary comparison 14 public, protect and private use 2java
In Java classes, the usage of these three keywords is different. Let’s look at a table first: private Most member variables are modified to be private, and they are not expected to be accessed by any other external class. Can only be accessed by member functions inside the class. default It is designed for access to this package. Any classes, interfaces, exceptions, etc. under this package can access each other, even members of the parent class that are not modified with protected. protected The main function is to protect subclasses. Its meaning is that subclasses can use the members it modifies, but not others. It is equivalent to an inherited thing passed to subclasses public Needless to say, you can access it from anywhere The code description is below. packageone folder under src, Alpha.java package packageone; public class Alpha { public void test() //By defining public member functions, instance access cannot be directly accessed to the outside world. { this.pub(); this.pro(); this.def(); this.pri(); } public void pub() //Define public member function { System.out.println( “public”); } protected void pro() //Define protected member function { System.out.println( “protected”); } void def() //Define default member function { System.out.println( “default”); } private void pri() //Define…
gopythonjavascala_[Transfer] Comparison of R, Python, Java, and Scala Go Language Chinese Community
Data Science,An exciting field just thinking about it,combines the most beautiful statistical knowledge with programming ability through different wisdom,a 1+1>2 field,and all the developments this year indicate that the glorious day of data science has arrived,whether it is big data,artificial intelligence,deep learning or data analysis, All are inseparable from data science. Data science is widely used in various fields,All programming languages are also accepting data science,So what is the best data science? Although there is no absolute Answer,But there are a few things to consider,After all, becoming a data scientist depends on many aspects: 1. Applicability In In data science we talked about, “if you want to go further”, it’s obviously not feasible to reinvent the wheel every time. It is necessary to learn and master the various software packages and tools provided in the chosen language – and a language with broad applicability and many packages will be a good choice. 2. Speed In the often fast-paced world of commercial data science , it is necessary to complete a job quickly,therefore, The speed of technology is taken into consideration – not only the speed of operation – but also the speed of learning. 3. Performance In some cases, it…
golangmysql query performance_C++, JAVA, Go comparison MySql database operation performance Go language Chinese community
Test environment: Windows 10 Professional Edition X64 CPU: intel Core i7-3612QM 2.1GHZ 4 cores 8 threads Memory: 8G C++: Visual Studio 2015 / MSVC 14 uses mysql official driver connector/C++ 1.17, boost 1.63.0 JAVA: jre 1.8.0_121 uses mysql official connector/j 5.1.40, jdbc driver go: go 1.8, Go does not have an official mysql driver, use github.com/Go -SQL-Driver/MySQL Test: insert 10,000 data into mysql and enable transactions C++ test source code: #include #include #include #include #include #include using namespace std; using namespace sql; int main() { mysql::MySQL_Driver* driver; Connection* con; Statement* state; LARGE_INTEGER beginTime; LARGE_INTEGER endTime; LARGE_INTEGER freQuency; driver = mysql::get_mysql_driver_instance(); try { con = driver->connect (“tcp://localhost:3306”, “myuser”, “123456”); state = con->createStatement(); state ->execute(“use mytestdb”); QueryPerformanceFrequency(&freQuency); QueryPerformanceCounter(&beginTime); SQLString sql = “insert into test_table values(NULL,’xxx’,’[email protected]’,’12345678′,’Promise Land’);”; con->setAutoCommit( false); for (int i = 0; i <10000; i++) { state-> execute(sql); } con->commit(); QueryPerformanceCounter(&endTime); con->setAutoCommit(true); } catch (SQLException &e) { cout <<"MySql Error:" <<e.what() <<endl; return -1; } unsigned long long escp = endTime.QuadPart – beginTime.QuadPart; cout <<"CPU:" <<freQuency .QuadPart <<endl; cout <<"TimeElapsed: " <<escp * 1000 / freQuency.QuadPart <<endl; delete state; delete con; return 0; } JAVA test source code: package testmysql; import java.sql.*; public class TMysql { public static void main(String[] args)…
TensorFlow’s API document address, interface and help documentation, TensorFlow opens Python, Java, C, Go interfaces
API Documentation TensorFlow has APIs in multiple languages that can be used to build and execute TensorFlow graphs. The Python API is currently the most complete and easiest to use, but other language APIs may be easier to integrate into projects and may provide some performance advantages in graph execution. Please note: APIs other than Python are not yet fully complete. Specific API coverage information: API stability promises. Python C Java Go We also provide a C API reference for TensorFlow Serving: : TensorFlow Serving We also encourage the community to develop and maintain support for other languages: approach recommended by the TensorFlow maintainers. For example, see the following languages: C#, Haskell, Julia, Ruby, Rust , and Scala.
go, java, netcore performance test records
Test logic: Loop 100,000 times to output and print hello world Test platform: windows Test results Language Memory occupied Packet size Time consuming go 5324k Executable file: 2172k Average 8502 milliseconds java 175326k Bytecode file: 2k Average 8537 milliseconds dotnetcore 3612k Packaging and publishing: 65.4m Average 8371 milliseconds Screenshot introduction go: Run main.exe directly Code: package mainimport ( “fmt” “os” ” os/signal” “syscall” “time”)func main() { t1 := time.Now() // get current time //logic handlers for i := 0; i <100000; i++ { fmt.Println(“hello world”) } elapsed := time.Since(t1) fmt.Println (“App elapsed: “, elapsed) sig := make(chan os.Signal, 2) signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT) <-sig } Directory after release java: Run the compiled bytecode file java HelloWorldCode import java.io.IOException;public class HelloWorld { public static void main(final String[] args) throws IOException { final long time1 = System.currentTimeMillis(); int i = 0; for (; i <100000; i++) { System. out.println(“hello world”); } final long time2 = System.currentTimeMillis(); System.out.println(“The current program takes time:” + (time2 – time1) + “ms”); System.in.read(); }} Compiled directory dotnetcore: Run netcore_prj.exe directlycode using System ;using System.Diagnostics;using System.Threading.Tasks;using System.Threading;namespace netcore_prj{ class Program { static async Task Main(string[] args) { var watch = new Stopwatch(); watch.Start(); for (var i = 0;…
Development notes: webserver programming in ABAP, Java, nodejs and go languages
Preface: This article is organized by the editor of Programming Notes#. It mainly introduces the knowledge related to web server programming in ABAP, Java, nodejs and go language. I hope it will be of certain reference value to you. ABAP and Java see my blog. nodejs Use the ready-made express module of nodejs to write a server with a few lines of code: var express = require(‘express’);var routesEngine = require(‘ ./jerryapp/routes/index.js’); // index.js actuallyhttp://www.ruanyifeng.com/blog/2015/05/require.htmlvar app = express();app.use(‘/ui5’, express.static(process.cwd() + ‘/webapp’));app.use(‘/ v’, express.static(process.cwd() + ‘/vue’));app.use(‘/map’, express.static(process.cwd() + ‘/map’));app.use(‘/tile’, express.static(process.cwd() + ‘/tileStudy’));app.use(‘/a2’, express.static(process.cwd() + ‘/a2’));routesEngine(app);app.listen(process.env.PORT || 3000, function () {console.log(‘Listening on port, process.cwd (): ‘ + process.cwd() );}); go To get more of Jerry’s original articles, please follow the public account “Wang Zixi”:
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…