summaryrefslogtreecommitdiff
path: root/src/stats.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-18 19:36:41 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-18 19:36:41 +0000
commit7e46119759b7099c38f543bd38d0186b9806542f (patch)
treeb31264c454e26566b2e70c2794b89d77f4e28c44 /src/stats.cpp
parent42592c0083505777e8fb8e4bf09182528229a787 (diff)
Remove excessive gettimeofday system calls
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12293 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/stats.cpp')
-rw-r--r--src/stats.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/stats.cpp b/src/stats.cpp
index b295db4a5..b272e0b6b 100644
--- a/src/stats.cpp
+++ b/src/stats.cpp
@@ -194,11 +194,10 @@ void InspIRCd::DoStats(char statschar, User* user, string_list &results)
results.push_back(sn+" 249 "+user->nick+" :Swaps: "+ConvToStr(R.ru_nswap));
results.push_back(sn+" 249 "+user->nick+" :Context Switches: Voluntary; "+ConvToStr(R.ru_nvcsw)+" Involuntary; "+ConvToStr(R.ru_nivcsw));
- timeval tv;
char percent[30];
- gettimeofday(&tv, NULL);
- float n_elapsed = ((tv.tv_sec - this->stats->LastSampled.tv_sec) * 1000000 + tv.tv_usec - this->stats->LastSampled.tv_usec);
+ float n_elapsed = (ServerInstance->Time() - this->stats->LastSampled.tv_sec) * 1000000
+ + (ServerInstance->Time_ns() - this->stats->LastSampled.tv_nsec) / 1000;
float n_eaten = ((R.ru_utime.tv_sec - this->stats->LastCPU.tv_sec) * 1000000 + R.ru_utime.tv_usec - this->stats->LastCPU.tv_usec);
float per = (n_eaten / n_elapsed) * 100;