c++11计时器宏定义
// TimerCount.h : Include file for standard system include files,
// or project specific include files.
#pragma once
#include <chrono>
#define TIMERSTARTS(tag) auto tag##_sta = std::chrono::steady_clock::now()
#define TIMEREND_SS(tag) auto tag##_end = std::chrono::steady_clock::now();printf("%s costs %d s\n",#tag,std::chrono::duration_cast<std::chrono::seconds>(tag##_end - tag##_sta).count())
#define TIMEREND_MS(tag) auto tag##_end = std::chrono::steady_clock::now();printf("%s costs %d ms\n",#tag,std::chrono::duration_cast<std::chrono::milliseconds>(tag##_end - tag##_sta).count())
#define TIMEREND_US(tag) auto tag##_end = std::chrono::steady_clock::now();printf("%s costs %d us\n",#tag,std::chrono::duration_cast<std::chrono::microseconds>(tag##_end - tag##_sta).count())
#define TIMEREND_NS(tag) auto tag##_end = std::chrono::steady_clock::now();printf("%s costs %d us\n",#tag,std::chrono::duration_cast<std::chrono::nanoseconds>(tag##_end - tag##_sta).count())
#pragma once
#include <chrono>
#define TIMERSTARTS(tag) auto tag##_sta = std::chrono::steady_clock::now()
#define TIMEREND_SS(tag) auto tag##_end = std::chrono::steady_clock::now();std::cout << #tag << " costs " << std::chrono::duration_cast<std::chrono::seconds>(tag##_end - tag##_sta).count() << "s" << std::endl
#define TIMEREND_MS(tag) auto tag##_end = std::chrono::steady_clock::now();std::cout << #tag << " costs " << std::chrono::duration_cast<std::chrono::milliseconds>(tag##_end - tag##_sta).count() << "ms" << std::endl
#define TIMEREND_US(tag) auto tag##_end = std::chrono::steady_clock::now();std::cout << #tag << " costs " << std::chrono::duration_cast<std::chrono::microseconds>(tag##_end - tag##_sta).count() << "us" << std::endl
#define TIMEREND_NS(tag) auto tag##_end = std::chrono::steady_clock::now();std::cout << #tag << " costs " << std::chrono::duration_cast<std::chrono::nanoseconds>(tag##_end - tag##_sta).count() << "us" << std::endl
#define TIMERCNT_SS(tagA,tagB) std::chrono::duration_cast<std::chrono::seconds>(tagA##_sta - taBg##_sta).count()
#define TIMERCNT_MS(tagA,tagB) std::chrono::duration_cast<std::chrono::milliseconds>(tagA##_sta - tagB##_sta).count()
#define TIMERCNT_US(tagA,tagB) std::chrono::duration_cast<std::chrono::microseconds>(tagA##_sta - tagB##_sta).count()
#define TIMERCNT_NS(tagA,tagB) std::chrono::duration_cast<std::chrono::nanoseconds>(tagA##_sta - tagB##_sta).count()