time elapse

/****************************************************************************
@File Name: test.cpp
@Author: wangzhicheng
@mail: 2363702560@qq.com
@Created Time: Sat 11 Feb 2017 08:23:01 PM CST
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <chrono>
using namespace std;
using namespace chrono;
int main()
{
	char buf[1024 * 1024];
	const int N = 100000;
	auto mystart = system_clock::now();
	for(int i = 0;i < N;i++)
	{
		bzero(buf, 0);		// bzero is much more faster than memset
//		memset(buf, 0, sizeof buf);
		buf[1024] = '1';
	}
	auto myend = system_clock::now();
	auto duration = duration_cast<microseconds>(myend - mystart);
	cout << static_cast<double>(duration.count()) * microseconds::period::num / microseconds::period::den << endl;

	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
将下面这段代码改用python写出来: clear all; close all; fdir = '../dataset/iso/saii/'; %Reconstruction parameters depth_start = 710; depth_end = 720; depth_step = 1; pitch = 12; sensor_sizex = 24; focal_length = 8; lens_x = 4; lens_y = 4; %% import elemental image infile=[fdir '11.bmp']; outfile=[fdir, 'EIRC/']; mkdir(outfile); original_ei=uint8(imread(infile)); [v,h,d]=size(original_ei); %eny = v/lens_y; enx = h/lens_x; % Calculate real focal length %f_ratio=36/sensor_sizex; sensor_sizey = sensor_sizex * (v/h); %focal_length = focal_length*f_ratio; EI = zeros(v, h, d, lens_x * lens_y,'uint8'); for y = 1:lens_y for x = 1:lens_x temp=imread([fdir num2str(y),num2str(x),'.bmp']); EI(:, :, :, x + (y-1) * lens_y) = temp; end end %Reconstruction [EIy, EIx, Color] = size(EI(:,:,:,1)); %% EI_VCR time=[]; for Zr = depth_start:depth_step:depth_end tic; Shx = 8*round((EIx*pitch*focal_length)/(sensor_sizex*Zr)); Shy = 8*round((EIy*pitch*focal_length)/(sensor_sizey*Zr)); Img = (double(zeros(EIy+(lens_y-1)*Shy,EIx+(lens_x-1)*Shx, Color))); Intensity = (uint16(zeros(EIy+(lens_y-1)*Shy,EIx+(lens_x-1)*Shx, Color))); for y=1:lens_y for x=1:lens_x Img((y-1)*Shy+1:(y-1)*Shy+EIy,(x-1)*Shx+1:(x-1)*Shx+EIx,:) = Img((y-1)*Shy+1:(y-1)*Shy+EIy,(x-1)*Shx+1:(x-1)*Shx+EIx,:) + im2double(EI(:,:,:,x+(y-1)*lens_y)); Intensity((y-1)*Shy+1:(y-1)*Shy+EIy,(x-1)*Shx+1:(x-1)*Shx+EIx,:) = Intensity((y-1)*Shy+1:(y-1)*Shy+EIy,(x-1)*Shx+1:(x-1)*Shx+EIx,:) + uint16(ones(EIy,EIx,Color)); end end elapse=toc time=[time elapse]; display(['--------------- Z = ', num2str(Zr), ' is processed ---------------']); Fname = sprintf('EIRC/%dmm.png',Zr); imwrite(Img./double(Intensity), [fdir Fname]); end csvwrite([fdir 'EIRC/time.csv'],time);
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值