Beispiel #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
Beispiel #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)
Beispiel #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()
Beispiel #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()
Beispiel #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()
Beispiel #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()
Beispiel #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)
Beispiel #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))
Beispiel #9
0
def op_ll_read_timestamp():
    from rpython.rlib.rtimer import read_timestamp

    return read_timestamp()
Beispiel #10
0
def _ll_0_ll_read_timestamp():
    from rpython.rlib import rtimer
    return rtimer.read_timestamp()
Beispiel #11
0
def rtimer_example():
    t1 = rtimer.read_timestamp()
    print rtimer.get_timestamp_unit()
    t2 = rtimer.read_timestamp()
    print t2 - t1
Beispiel #12
0
 def bh_read_timestamp(self):
     return read_timestamp()
Beispiel #13
0
def op_ll_read_timestamp():
    from rpython.rlib.rtimer import read_timestamp
    return read_timestamp()
Beispiel #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)
Beispiel #15
0
def _ll_0_ll_read_timestamp():
    from rpython.rlib import rtimer
    return rtimer.read_timestamp()
def debug_read_timestamp(space):
    return space.newint(rtimer.read_timestamp())