On Fri, Dec 30, 2016 at 1:02 PM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> Haribabu Kommi <kommi.harib...@gmail.com> writes: > > Attached a patch that replaces most of the getimeofday function calls, > > except timeofday(user callable) and GetCurrentTimestamp functions. > > I looked at this for awhile and could not convince myself that it's > a good idea. Trying to do s/gettimeofday/clock_gettime/g is not going > to do much for us except create portability headaches. According > to my tests, clock_gettime is not noticeably faster than gettimeofday > on any platform, except that if you use nonstandard clockids like > CLOCK_REALTIME_COARSE then on *some* platforms it's a little bit quicker, > at the cost of being a great deal less precise. But we'd have to research > the existence and effects of nonstandard clockids on every platform. > So AFAICS the only clear advantage to switching is the extra precision > available from clock_gettime. > > But ... most of the places you've touched in this patch have neither any > need for sub-microsecond precision nor any great need to worry about > shaving a few ns off the time taken by the call. As far as I can find, > the only place where it's actually worth our trouble to deal with it is > instr_time.h (ie, EXPLAIN ANALYZE and a few other uses). > > So I think we should do something more like the attached. > Thanks for your valuable input. As the getimeofday() function is obsolete and any further enhancements may happen to clock_gettime() function only, because of this reason, I changed it many places. Yes, I agree that until unless the clock_gettime() function that performs faster in all platforms compared to gettimeofday(), we can retain the getimeofday() function. Regards, Hari Babu Fujitsu Australia