⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.cpp

📁 signal-processing.rar信号处理demo原码
💻 CPP
字号:
/*
//
//               INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//    Copyright (c) 2006 Intel Corporation. All Rights Reserved.
//
*/

#include "ippcore.h"
#include "timer.h"


CTimer::CTimer(void)
{
  m_c0 = 0;
  m_c1 = 0;

#ifdef _WIN32
  m_freq.QuadPart = 0;
  m_t0.QuadPart = 0;
  m_t1.QuadPart = 0;

  QueryPerformanceFrequency(&m_freq);
#endif

#ifdef linux
  m_t0 = 0;
  m_t1 = 0;
#endif

  return;
} // ctor


CTimer::~CTimer(void)
{
  return;
} // dtor


void CTimer::Init(void)
{
#ifdef _WIN32
  QueryPerformanceFrequency(&m_freq);
#endif
  return;
} // CTimer::Init()


void CTimer::Start(void)
{
#ifdef _WIN32
  QueryPerformanceCounter(&m_t0);
#endif

#ifdef linux
  m_t0 = clock();
#endif

  m_c0 = ippGetCpuClocks();

  return;
} // CTimer::Start()


void CTimer::Stop(void)
{
#ifdef _WIN32
  QueryPerformanceCounter(&m_t1);
#endif

#ifdef linux
  m_t1 = clock();
#endif

  m_c1 = ippGetCpuClocks();

  return;
} // CTimer::Stop()


void CTimer::RaisePriority(void)
{
#ifdef _WIN32
  SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);
  Sleep(0);
#endif
  return;
} // CTimer::RaisePriority()


void CTimer::LowerPriority(void)
{
#ifdef _WIN32
  SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_NORMAL);
#endif
  return;
} // CTimer::LowerPriority()


Ipp64u CTimer::GetCpuClocks(void)
{
  return (m_c1 - m_c0);
} // CTimer::GetCpuClocks()


double CTimer::GetTime(CTimer::units u)
{
  double t;
#ifdef _WIN32
  t = (double)(m_t1.QuadPart - m_t0.QuadPart) / m_freq.QuadPart;
#endif

#ifdef linux
  t = (double)(m_t1 - m_t0) / CLOCKS_PER_SEC;
#endif

  switch(u)
  {
  case usec: t = (USEC)*t; break;
  case msec: t = (MSEC)*t; break;
  case sec:
  default:
    break;
  }

  return t;
} // CTimer::GetTime()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -