测试简单for循环的效率
os : CentOS 5.2
代码:test-usecond.c
#include <stdio.h>
#include <sys/time.h> // for gettimeofday() int main()
{
struct timeval tmlist[];
int i = ;
for(i = ; i < ; i++)
{
gettimeofday( &tmlist[i], NULL );
}
for(i = ; i < ; i++)
{
int iItvl = ;
if(i > )
{
iItvl = tmlist[i].tv_usec - tmlist[i - ].tv_usec;
}
printf("tm[%2d] : %d.%06d -> %d\n", i, tmlist[i].tv_sec, tmlist[i].tv_usec, iItvl);
}
}
运行结果:
tm[ 0] : 1422847341.193135 -> 0
tm[ 1] : 1422847341.193136 ->
tm[ 2] : 1422847341.193136 -> 0
tm[ 3] : 1422847341.193136 -> 0
tm[ 4] : 1422847341.193137 -> 1
tm[ 5] : 1422847341.193137 -> 0
tm[ 6] : 1422847341.193137 -> 0
tm[ 7] : 1422847341.193138 -> 1
tm[ 8] : 1422847341.193138 -> 0
tm[ 9] : 1422847341.193138 -> 0
tm[10] : 1422847341.193139 -> 1
tm[11] : 1422847341.193139 -> 0
tm[12] : 1422847341.193139 -> 0
tm[13] : 1422847341.193140 -> 1
tm[14] : 1422847341.193140 -> 0
tm[15] : 1422847341.193140 -> 0
tm[16] : 1422847341.193141 -> 1
tm[17] : 1422847341.193141 -> 0
tm[18] : 1422847341.193141 -> 0
tm[19] : 1422847341.193141 -> 0
tm[20] : 1422847341.193142 -> 1
tm[21] : 1422847341.193142 -> 0
tm[22] : 1422847341.193142 -> 0
tm[23] : 1422847341.193143 -> 1
tm[24] : 1422847341.193143 -> 0
tm[25] : 1422847341.193143 -> 0
tm[26] : 1422847341.193144 -> 1
tm[27] : 1422847341.193144 -> 0
tm[28] : 1422847341.193144 -> 0
tm[29] : 1422847341.193145 -> 1
tm[30] : 1422847341.193145 -> 0
tm[31] : 1422847341.193145 -> 0
tm[32] : 1422847341.193146 -> 1
tm[33] : 1422847341.193146 -> 0
tm[34] : 1422847341.193146 -> 0
tm[35] : 1422847341.193146 -> 0
tm[36] : 1422847341.193147 -> 1
tm[37] : 1422847341.193147 -> 0
tm[38] : 1422847341.193147 -> 0
tm[39] : 1422847341.193148 -> 1
tm[40] : 1422847341.193148 -> 0
tm[41] : 1422847341.193148 -> 0
tm[42] : 1422847341.193149 -> 1
tm[43] : 1422847341.193149 -> 0
tm[44] : 1422847341.193149 -> 0
tm[45] : 1422847341.193150 -> 1
tm[46] : 1422847341.193150 -> 0
tm[47] : 1422847341.193150 -> 0
tm[48] : 1422847341.193151 -> 1
tm[49] : 1422847341.193151 -> 0
测试简单for循环的效率的更多相关文章
- python 几个循环的效率测试
前言:对于我这种追求极致的人来说,效率很重要. 前面看到网上关于python循环的测评,到自己在项目中的应用,发现,并不是这么回事.所以,写下次博文,一次性了解这个问题. 语言版本:python3.6 ...
- Spring IOC 方式结合TESTGN测试用例,测试简单java的命令模式
java命令模式: 可以命令("请求")封装成一个对象,一个命令对象通过在特定的接收着上绑定一组动作来封装一个请求.命令对象直接把执行动作和接收者包进对象中,只对外暴露出执行方法的 ...
- python实现简单的循环购物车小功能
python实现简单的循环购物车小功能 # -*- coding: utf-8 -*- __author__ = 'hujianli' shopping = [ ("iphone6s&quo ...
- JMeter压力测试简单使用
原创:转载需注明原创地址 https://www.cnblogs.com/fanerwei222/p/11915535.html JMeter压力测试简单使用: 我们可以使用JMeter来测试一下自己 ...
- java中的Iterator与增强for循环的效率比较
最近在优化代码时遇到了这个问题:Iterator与增强for循环到底哪个效率高?之前在学习的时候,好像记着老师说过遍历集合(如list)时,使用iterator好像正规一些,因为是专用的,但是运行效率 ...
- bash脚本编程之二 字符串测试及for循环
shell中大量的测试和比较选项而困惑呢? 这个技巧可以帮助您解密不同类型的文件.算术和字符串测试,这样您就能够知道什么时候使用 test. [ ]. [[ ]].(( )) 或 if-then-el ...
- 计算机基础,Python基础--变量以及简单的循环
一.计算机基础 1.CPU 相当于人体的大脑,用于计算处理数据. 2.内存 用于存储数据,CPU从内存调用数据处理计算,运算速度很快. PS:问:既然在内存里的数据CPU运算速度快,为什么计算机不全 ...
- Java实现一个简单的循环队列
在某些时候,我们不能被要求像数组一样可以使用索引随机访问,而是需要被限制顺序处理业务,今天介绍一种先进先出(FIFO)的线性数据结构:队列, 当然,还有后进先出(LIFO)的处理方式,即为栈(后续有时 ...
- Jmeter压力测试简单教程(包括服务器状态监控)
前段时间公司需要对服务器进行压力测试,包括登录前的页面和登录后的页面,主要目的是测试负载均衡的实现效果.不知道是不是因为Jmeter不如loadRunner火爆还是什么,网上关于Jmeter的资料有很 ...
随机推荐
- AOJ673 聪明的输入法(字典树)
#include<cstdio> #include <cstdlib> #include <cstring> #include <iostream> # ...
- android 入门-android Studio 解决方案
一.当提示 解决方案: 1. 2. 二.从这步到这步 的时候,可能遇见下面的问题. 解决方案: 更新一下build-tools 19.1.0版本 放到你的sdk里并重启as. 三. 当遇见这样的情况 ...
- jquery audio player
<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8&quo ...
- javascript 获取url参数值
function getvl(name) { var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s| ...
- slide.js使用文档
<!doctype html> <head> <script src="js/jquery-latest.min.js"></script ...
- 【转】使用jquery animate创建平滑滚动效果
这篇文章主要介绍了使用jquery animate创建平滑滚动效果,效果可以滚动到顶部.到底部或页面中指定地方,生要的是非常平滑,很舒服,需要的朋友可以参考下 滚动到顶部: $('.scroll_to ...
- JavaScript模拟函数重载
JavaScript是没有函数重载的,但是我们可以通过其他方法来模拟函数重载,如下所示: <!DOCTYPE html> <html> <head> <met ...
- jvm运行机制与内存管理
http://blog.csdn.net/lengyuhong/article/details/5953544 http://www.cnblogs.com/nexiyi/p/java_memory_ ...
- MOB 短信验证
工具/原料 Android Studio mob SDK中的jar 和.so文件 方法/步骤 1 把3个jar 放入libs 并添加依赖 在项目的build.gradle里面 在你的项 ...
- HTTP基础06--网络安全
HTTP 的缺点 通信使用明文可能会被窃听 HTTP 报文使用明文(指未经过加密的报文)方式发送. 通信的加密 用 SSL 建立安全通信线路之后,就可以在这条线路上进行 HTTP 通信了.与 SSL ...