Пример #1
0
def timer():
    t1 = read_timestamp()
    start = time.time()
    while time.time() - start < 0.1:
        # busy wait
        pass
    t2 = read_timestamp()
    return t2 - t1
Пример #2
0
def do_read_timestamp(cpu, _):
    x = read_timestamp()
    if longlong.is_64_bit:
        assert is_valid_int(x)            # 64-bit
        return BoxInt(x)
    else:
        assert isinstance(x, r_longlong)  # 32-bit
        return BoxFloat(x)
Пример #3
0
 def disable(self, space):
     if not self.is_enabled:
         return  # ignored
     # We want total_real_time and total_timestamp to end up containing
     # (endtime - starttime), or the sum of such intervals if
     # enable() and disable() are called several times.
     self.is_enabled = False
     self.total_timestamp += read_timestamp()
     self.total_real_time += time.time()
     # unset profiler hook
     space.getexecutioncontext().setllprofile(None, None)
     c_teardown_profiling()
     self._flush_unmatched()
Пример #4
0
 def ll_timer(self):
     if self.w_callable:
         space = self.space
         try:
             if _is_64_bit:
                 return space.int_w(space.call_function(self.w_callable))
             else:
                 return space.r_longlong_w(
                     space.call_function(self.w_callable))
         except OperationError as e:
             e.write_unraisable(space, "timer function ", self.w_callable)
             return timer_size_int(0)
     return read_timestamp()
Пример #5
0
 def disable(self, space):
     if not self.is_enabled:
         return      # ignored
     # We want total_real_time and total_timestamp to end up containing
     # (endtime - starttime), or the sum of such intervals if
     # enable() and disable() are called several times.
     self.is_enabled = False
     self.total_timestamp += read_timestamp()
     self.total_real_time += time.time()
     # unset profiler hook
     space.getexecutioncontext().setllprofile(None, None)
     c_teardown_profiling()
     self._flush_unmatched()
Пример #6
0
 def ll_timer(self):
     if self.w_callable:
         space = self.space
         try:
             if _is_64_bit:
                 return space.int_w(space.call_function(self.w_callable))
             else:
                 return space.r_longlong_w(space.call_function(self.w_callable))
         except OperationError as e:
             e.write_unraisable(space, "timer function ",
                                self.w_callable)
             return timer_size_int(0)
     return read_timestamp()
Пример #7
0
 def enable(self, space, w_subcalls=None, w_builtins=None):
     if self.is_enabled:
         return  # ignored
     if w_subcalls is not None:
         self.subcalls = space.bool_w(w_subcalls)
     if w_builtins is not None:
         self.builtins = space.bool_w(w_builtins)
     # We want total_real_time and total_timestamp to end up containing
     # (endtime - starttime).  Now we are at the start, so we first
     # have to subtract the current time.
     self.is_enabled = True
     self.total_real_time -= time.time()
     self.total_timestamp -= read_timestamp()
     # set profiler hook
     c_setup_profiling()
     space.getexecutioncontext().setllprofile(lsprof_call, self)
Пример #8
0
 def enable(self, space, w_subcalls=None,
            w_builtins=None):
     if self.is_enabled:
         return      # ignored
     if w_subcalls is not None:
         self.subcalls = space.bool_w(w_subcalls)
     if w_builtins is not None:
         self.builtins = space.bool_w(w_builtins)
     # We want total_real_time and total_timestamp to end up containing
     # (endtime - starttime).  Now we are at the start, so we first
     # have to subtract the current time.
     self.is_enabled = True
     self.total_real_time -= time.time()
     self.total_timestamp -= read_timestamp()
     # set profiler hook
     c_setup_profiling()
     space.getexecutioncontext().setllprofile(lsprof_call, space.wrap(self))
Пример #9
0
def op_ll_read_timestamp():
    from rpython.rlib.rtimer import read_timestamp

    return read_timestamp()
Пример #10
0
def _ll_0_ll_read_timestamp():
    from rpython.rlib import rtimer
    return rtimer.read_timestamp()
Пример #11
0
def rtimer_example():
    t1 = rtimer.read_timestamp()
    print rtimer.get_timestamp_unit()
    t2 = rtimer.read_timestamp()
    print t2 - t1
Пример #12
0
 def bh_read_timestamp(self):
     return read_timestamp()
Пример #13
0
def op_ll_read_timestamp():
    from rpython.rlib.rtimer import read_timestamp
    return read_timestamp()
Пример #14
0
def tiger_start_timer():
    """Native function to start a timer; in RPython this will measure the CPU ticks with RDTSC, see
    genop_math_read_timestamp in pypy/rpython/jit/backend/x86/assembler.py"""
    start_timestamp.value = read_timestamp()
    return IntegerValue(start_timestamp.value)
Пример #15
0
def _ll_0_ll_read_timestamp():
    from rpython.rlib import rtimer
    return rtimer.read_timestamp()
Пример #16
0
def debug_read_timestamp(space):
    return space.newint(rtimer.read_timestamp())