C/C++、JAVA、Python简单运行速度实验与分析
生活随笔
收集整理的这篇文章主要介绍了
C/C++、JAVA、Python简单运行速度实验与分析
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
C/C++
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> using namespace std; int main() {int count=0;for(int i=1;i<=1e7;i++)count++;printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);return 0; }运行时间:0.012000s
JAVA
public class Main {public static void main(String[] args) {long startTime=System.currentTimeMillis();int count=0;for(int i=1;i<=1e7;i++)count++;long endTime=System.currentTimeMillis();System.out.println("程序运行时间: "+(endTime - startTime)+"ms");}}运行时间:0.011000s
Python
import time start=time.perf_counter() count=1 for i in range(10000000):count+1 end=time.perf_counter() print(end-start)运行时间:0.531215s
分析
参考文章
https://blog.csdn.net/qq_36868342/article/details/82838041
https://www.cnblogs.com/nucdy/p/6703780.html
http://baijiahao.baidu.com/s?id=1586231401218732290&wfr=spider&for=pc
https://blog.csdn.net/csdnnews/article/details/81213229
总结
以上是生活随笔为你收集整理的C/C++、JAVA、Python简单运行速度实验与分析的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Linux——主流发行版本
- 下一篇: C++——赫夫曼编码-译码器(Huffm