зеркало из https://github.com/github/ruby.git
mjit.c: measure time more precisely
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1ae9fad62d
Коммит
b701946418
5
mjit.c
5
mjit.c
|
@ -219,6 +219,10 @@ static char *libruby_pathflag;
|
|||
static void remove_file(const char *filename);
|
||||
|
||||
/* Return time in milliseconds as a double. */
|
||||
#ifdef __APPLE__
|
||||
double ruby_real_ms_time(void);
|
||||
#define real_ms_time() ruby_real_ms_time()
|
||||
#else
|
||||
static double
|
||||
real_ms_time(void)
|
||||
{
|
||||
|
@ -239,6 +243,7 @@ real_ms_time(void)
|
|||
return tv.tv_usec / 1000.0 + tv.tv_sec * 1000.0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make and return copy of STR in the heap. */
|
||||
#define get_string ruby_strdup
|
||||
|
|
14
process.c
14
process.c
|
@ -7184,7 +7184,7 @@ make_clock_result(struct timetick *ttp,
|
|||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
static mach_timebase_info_data_t *
|
||||
static const mach_timebase_info_data_t *
|
||||
get_mach_timebase_info(void)
|
||||
{
|
||||
static mach_timebase_info_data_t sTimebaseInfo;
|
||||
|
@ -7195,6 +7195,14 @@ get_mach_timebase_info(void)
|
|||
|
||||
return &sTimebaseInfo;
|
||||
}
|
||||
|
||||
double
|
||||
ruby_real_ms_time(void)
|
||||
{
|
||||
const mach_timebase_info_data_t *info = get_mach_timebase_info();
|
||||
uint64_t t = mach_absolute_time();
|
||||
return (double)t * info->numer / info->denom / 1e6;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -7450,7 +7458,7 @@ rb_clock_gettime(int argc, VALUE *argv)
|
|||
#ifdef __APPLE__
|
||||
#define RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC ID2SYM(id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC)
|
||||
if (clk_id == RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) {
|
||||
mach_timebase_info_data_t *info = get_mach_timebase_info();
|
||||
const mach_timebase_info_data_t *info = get_mach_timebase_info();
|
||||
uint64_t t = mach_absolute_time();
|
||||
tt.count = (int32_t)(t % 1000000000);
|
||||
tt.giga_count = t / 1000000000;
|
||||
|
@ -7589,7 +7597,7 @@ rb_clock_getres(int argc, VALUE *argv)
|
|||
|
||||
#ifdef RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC
|
||||
if (clk_id == RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) {
|
||||
mach_timebase_info_data_t *info = get_mach_timebase_info();
|
||||
const mach_timebase_info_data_t *info = get_mach_timebase_info();
|
||||
tt.count = 1;
|
||||
tt.giga_count = 0;
|
||||
numerators[num_numerators++] = info->numer;
|
||||
|
|
Загрузка…
Ссылка в новой задаче