Re: SLOW syslog() function
Ken Snider <[email protected]>
| Newsgroups | gmane.linux.redhat.release.taroon.general |
|---|---|
| Organization | Datawire Communication Networks Inc. |
| Message-ID | <[email protected]> |
Shaw, Marco wrote:
> I was going to give this a try on RHEL4, they maybe give
> systemtap a run at it.
Following Arjan's comments, I'm going to attempt to tweak I/O under RHEL3
and see what effect that has. the RHEL4 results will be interesting to see,
however.
> Where does this timevalue.h come from?
Gah, knew I'd forget that. Here's the file.
---
#include <sys/time.h>
class Time
{
private:
// the time value managed by this object
struct timeval time_;
public:
/**
* Constructor
* Parameters: second - the initial value to set for
* this object
**/
Time(long second = 0, long usecond = 0)
{
time_.tv_sec = second;
time_.tv_usec = usecond;
}
/**
* Copy Constructor
**/
Time(const Time& T) : time_(T.time_) {}
/**
* Method: MilliSecond
* Parameters: None.
* Returns: time in milli-seconds.
**/
long MilliSecond() const
{
return ((time_.tv_sec * 1000) + (time_.tv_usec / 1000));
}
/**
* Method: CurrentTime
* Parameters: None.
* Returns: Nothing.
* Purpose: Set the time value of this object to be
* the current time
**/
void CurrentTime() { gettimeofday(&time_, NULL); }
/**
* Operator: -=
* Parameters: T - the RHS of the equation
* Returns: Time& to this object.
* Purpose: Specify functionality of the
* decrement-by and assign operator
**/
Time& operator-= (const Time& T)
{
long long t1, t2;
t1 = (long long)time_.tv_sec;
t1 *= USECONDS_PER_SECOND;
t1 += (long long)time_.tv_usec;
t2 = (long long)T.time_.tv_sec;
t2 *= USECONDS_PER_SECOND;
t2 += (long long)T.time_.tv_usec;
t1 -= t2;
time_.tv_sec = (long)(t1 / USECONDS_PER_SECOND);
time_.tv_usec = (long)(t1 % USECONDS_PER_SECOND);
return *this;
}
};
/**
* Operator: -
* Parameters: lhs - the leftmost opperand
* rhs - the rightmost opperand
* Returns: const Time containing the result of lhs - rhs.
* Purpose: Perform the addition of lhs - rhs.
**/
inline const Time operator- (const Time& lhs, const Time& rhs)
{
Time T( lhs );
T -= rhs;
return T;
}
---
--
Ken Snider
--
Taroon-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/taroon-list