1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
/************************************************************************************
Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
Alex Pothen
This file is part of ColPack.
ColPack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ColPack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ColPack. If not, see <http://www.gnu.org/licenses/>.
************************************************************************************/
//using namespace std;
#include "Definitions.h"
#include "Timer.h"
namespace ColPack
{
//Public Constructor 4351
Timer::Timer()
{
}
//Public Destructor 4352
Timer::~Timer()
{
}
//Public Function 4354
void Timer::Start()
{
#ifdef SYSTEM_TIME
ct_BeginTimer = times(&tms_BeginTimer);
#else
ct_BeginTimer = clock();
#endif
}
//Public Function 4355
void Timer::Stop()
{
#ifdef SYSTEM_TIME
ct_EndTimer = times(&tms_EndTimer);
#else
ct_EndTimer = clock();
#endif
}
//Public Function 4356
double Timer::GetWallTime()
{
#ifdef SYSTEM_TIME
return (double)(ct_EndTimer - ct_BeginTimer) / CLK_TCK;
#else
return (double)(ct_EndTimer - ct_BeginTimer) / CLOCKS_PER_SEC;
#endif
}
//Public Function 4357
double Timer::GetProcessorTime()
{
#ifdef SYSTEM_TIME
double t_UserTime = (double) (tms_EndTimer.tms_utime - tms_BeginTimer.tms_utime) / CLK_TCK;
double t_SystemTime = (double) (tms_EndTimer.tms_stime - tms_BeginTimer.tms_stime) / CLK_TCK;
return(t_UserTime + t_SystemTime);
#else
return(_UNKNOWN);
#endif
}
//Public Function 4358
double Timer::GetUserProcessorTime()
{
#ifdef SYSTEM_TIME
double t_UserTime = (double)(tms_EndTimer.tms_utime - tms_BeginTimer.tms_utime) / CLK_TCK;
return(t_UserTime);
#else
return(_UNKNOWN);
#endif
}
//Public Function 4359
double Timer::GetSystemProcessorTime()
{
#ifdef SYSTEM_TIME
double t_SystemTime = (double)(tms_EndTimer.tms_stime - tms_BeginTimer.tms_stime) / CLK_TCK;
return(t_SystemTime);
#else
return(_UNKNOWN);
#endif
}
}
|