当前位置:网站首页>js中如何查看程序运行时间(计时器)
js中如何查看程序运行时间(计时器)
2022-06-27 07:20:00 【I am the sun?】
我们可以在要测试代码的最前面加上:
console.time(“计时器名字”);
测试代码最后加上:
console.timeEnd(“计时器名字”);
如下代码:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="text/javascript">
console.time("test");
var sum = 0;
for(var i = 1;i <= 100;i++){
var flag = true;
if(i == 1)
flag = false;
for(var j = 2;j < i;j++){
if(i % j == 0){
flag = false;
break;
}
}
if(flag){
document.write(i + " ");
sum++;
}
}
document.write("<br />质数一共有:" + sum + " 个。");
console.timeEnd("test");
</script>
</head>
<body>
</body>
</html>

边栏推荐
- RNA SEQ data analysis in R - investigate differentially expressed genes in the data!
- 2022 cisp-pte (I) document contains
- hutool对称加密
- Visual studio vs shortcut key usage
- 使用 Blackbox Exporter 测试网络连通性
- The interviewer of a large front-line factory asked: do you really understand e-commerce order development?
- ggplot2的自定义调色板
- Bean拷贝详解
- 语音信号处理-概念(一):时谱图(横轴:时间;纵轴:幅值)、频谱图(横轴:频率;纵轴:幅值)--傅里叶变换-->时频谱图【横轴:时间;纵轴:频率;颜色深浅:幅值】
- Self test in the second week of major 4
猜你喜欢

Multi table associated query -- 07 -- hash join

IDEA连接数据库报错

语音信号处理-概念(二):幅度谱(短时傅里叶变换谱/STFT spectrum)、梅尔谱(Mel spectrum)【语音的深度学习主要用幅度谱、梅尔谱】【用librosa或torchaudio提取】

正斜杠反斜杠的由来

yarn create vite 报错 ‘D:\Program‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件

Interviewer: do you have any plan to request a lot of data that does not exist in redis to destroy the database?

2022 cisp-pte (II) SQL injection

2022 cisp-pte (I) document contains

Configuring FTP, enterprise official website, database and other methods for ECS

Yarn create vite reports an error 'd:\program' which is neither an internal or external command nor a runnable program or batch file
随机推荐
The interviewer of a large front-line factory asked: do you really understand e-commerce order development?
Idea方法模板
Delay queue `delayqueue`
Memory barrier store buffer, invalid queue
【软件工程】山东大学软件工程复习提纲
Apifox learning
Visual studio vs shortcut key usage
Talk about Domain Driven Design
语音信号特征提取流程:输入语音信号-分帧、预加重、加窗、FFT->STFT谱(包括幅度、相位)-对复数取平方值->幅度谱-Mel滤波->梅尔谱-取对数->对数梅尔谱-DCT->FBank->MFCC
Websocket database listening
YOLOv6又快又准的目标检测框架 已开源
How torch. gather works
JDBC reads MySQL data list
One person manages 1000 servers? This automatic operation and maintenance tool must be mastered
Yolov6's fast and accurate target detection framework is open source
剑指 Offer 07. 重建二叉树
数据库系统工程师对口专业有哪些?
Interviewer: you use Lombok every day. What is its principle? I can't answer
[Software Engineering] software engineering review outline of Shandong University
Coggle 30 Days of ML 7月竞赛学习