Linux c++ time different
下面这个函数可以得到微秒级别:
#include<time.h>int clock_gettime(clockid_t clk_id,struct timespec *tp);clock_gettime函数#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sys/time.h>
#include <time.h>
#include <string> using namespace std; string encodeGeohash(const double & theLat, const double & theLong, int thePrecision); int main(int argc, char **argv)
{
const int MILLION = ;
double aLat = -80.11111111111;
double aLong = -170.111111111111;
struct timespec tpstart;
struct timespec tpend;
long timedif;
clock_gettime(CLOCK_MONOTONIC, &tpstart);
int i = ;
for(i = ; i < ; i++)
{
encodeGeohash(aLat, aLong, );
aLat += 0.000001;
aLong += 0.000001;
} clock_gettime(CLOCK_MONOTONIC, &tpend);
timedif = MILLION*(tpend.tv_sec-tpstart.tv_sec)+(tpend.tv_nsec-tpstart.tv_nsec)/;
std::cout << "i = " << i << "\t timedif = " << timedif << std::endl; return ;
}
Linux c++ time different的更多相关文章
- Linux 驱动开发
linux驱动开发总结(一) 基础性总结 1, linux驱动一般分为3大类: * 字符设备 * 块设备 * 网络设备 2, 开发环境构建: * 交叉工具链构建 * NFS和tftp服务器安装 3, ...
- Linux 内核概述 - Linux Kernel
Linux 内核学习笔记整理. Unix unix 已有40历史,但计算机科学家仍认为其是现存操作系统中最大和最优秀的系统,它已成为一种传奇的存在,历经时间的考验却依然声名不坠. 1973 年,在用 ...
- 死磕内存篇 --- JAVA进程和linux内存间的大小关系
运行个JAVA 用sleep去hold住 package org.hjb.test; public class TestOnly { public static void main(String[] ...
- NodeJs在Linux下使用的各种问题
环境:ubuntu16.04 ubuntu中安装NodeJs 通过apt-get命令安装后发现只能使用nodejs,而没有node命令 如果想避免这种情况请看下面连接的这种安装方式: 拓展见:Linu ...
- [linux]阿里云主机的免登陆安全SSH配置与思考
公司服务器使用的第三方云端服务,即阿里云,而本地需要经常去登录到服务器做相应的配置工作,鉴于此,每次登录都要使用密码是比较烦躁的,本着极速思想,我们需要配置我们的免登陆. 一 理论概述 SSH介绍 S ...
- Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part3:db安装和升级
Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part3:db安装和升级 环境:OEL 5.7 + Oracle 10.2.0.5 RAC 5.安装Database软件 5. ...
- Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part1:准备工作
Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part1:准备工作 环境:OEL 5.7 + Oracle 10.2.0.5 RAC 1.实施前准备工作 1.1 服务器安装操 ...
- SQL Server on Linux 理由浅析
SQL Server on Linux 理由浅析 今天的爆炸性新闻<SQL Server on Linux>基本上在各大科技媒体上刷屏了 大家看到这个新闻都觉得非常震精,而美股,今天微软开 ...
- Microsoft Loves Linux
微软新任CEO纳德拉提出的“Microsoft Loves Linux”,并且微软宣布.NET框架的开源,近期Microsoft不但宣布了Linux平台的SQL Server,还宣布了Microsof ...
- Linux 江湖系列阶段性总结
引言 我使用 Linux 已经有很多年了,最开始接触 Linux 的时候是从 RedHat 9(没有 Enterprise),中途换过 N 个不同的发行版.多年前,我在 BlogJava 上面分享 J ...
随机推荐
- Javascript中点击(click)事件的3种写法
方法一 <!DOCTYPE html> <html> <head> <title>Javascript中点击事件方法一</title> &l ...
- HDU 1715 斐波那契数列1000项
二维数组模拟大数加法就可以了,不太难,直接上代码了. #include<stdio.h> #include<string.h> #include<math.h> # ...
- [c][c++]按位操作
因为有时候需要大量的标志位来判断当前状态等.使用太多的int,bool等会使得程序不“漂亮” 这时候需要“位”操作来解决 建立一个标志位 unsigned ; 在定义一些宏,如 #define CON ...
- ubuntu18重装后 基本需求安装
以下为本人重装ubuntu18后的基本需求安装过程 1 apt-fast sudo add-apt-repository ppa:apt-fast/stable sudo apt-get update ...
- SPOJ 刷题记录
按点赞数降序 297 二分 #include<bits/stdc++.h> using namespace std; #define fi first #define se second ...
- Unity---关于游戏小包的记录
最近因为需求,出了一个pc版的游戏小包,遇到一些坑,在此做一下记录. 首先需要明白的是出小包的意义所在,其实就是为了压缩包体,游戏需要的大部分资源,在第一次运行游戏的时候通过热更新去FTP资源服务器上 ...
- Asp.net core 学习笔记 ( upload/download files 文件上传与下载 )
更新 : 2018-01-22 之前漏掉了一个 image 优化, 就是 progressive jpg refer : http://techslides.com/demos/progressi ...
- L1 正则为什么会使参数偏向稀疏
2018-12-09 22:18:43 假设费用函数 L 与某个参数 x 的关系如图所示: 则最优的 x 在绿点处,x 非零. 现在施加 L2 regularization,新的费用函数()如图中蓝线 ...
- webpack基础概念
中文文档:https://webpack.docschina.org/concepts/ 一个现代 JavaScript 应用程序的静态模块打包器(static module bundler). 在 ...
- p1209 Barn Repair
用优先队列存放不连续的断点及断的位置.优先取间距大的,在断点断开. #include <iostream> #include <cstdio> #include <cma ...