8241638: launcher time metrics always report 1 on Linux when _JAVA_LAUNCHER_DEBUG set

Reviewed-by: alanb, dholmes
This commit is contained in:
Lin Zang 2020-04-07 03:25:11 +00:00 committed by Henry Jen
parent e18d66174a
commit b317d0ee39
5 changed files with 35 additions and 14 deletions

View file

@ -813,3 +813,24 @@ ProcessPlatformOption(const char *arg)
{
return JNI_FALSE;
}
#ifndef __solaris__
/*
* Provide a CounterGet() implementation based on gettimeofday() which
* is universally available, even though it may not be 'high resolution'
* compared to platforms that provide gethrtime() (like Solaris). It is
* also subject to time-of-day changes, but alternatives may not be
* known to be available at either build time or run time.
*/
uint64_t CounterGet() {
uint64_t result = 0;
struct timeval tv;
if (gettimeofday(&tv, NULL) != -1) {
result = 1000000LL * (uint64_t)tv.tv_sec;
result += (uint64_t)tv.tv_usec;
}
return result;
}
#endif // !__solaris__

View file

@ -26,17 +26,17 @@
#ifndef JAVA_MD_SOLINUX_H
#define JAVA_MD_SOLINUX_H
#ifdef HAVE_GETHRTIME
#include <sys/time.h>
#ifdef __solaris__
/*
* Support for doing cheap, accurate interval timing.
*/
#include <sys/time.h>
#define CounterGet() (gethrtime()/1000)
#define Counter2Micros(counts) (counts)
#else /* ! HAVE_GETHRTIME */
#define CounterGet() (0)
#define Counter2Micros(counts) (1)
#endif /* HAVE_GETHRTIME */
#else /* ! __solaris__ */
uint64_t CounterGet(void);
#define Counter2Micros(counts) (counts)
#endif /* __solaris__ */
/* pointer to environment */
extern char **environ;