Ejemplo n.º 1
0
    def test_raw_conversion(self):
        now_t = tsc_time.now_tsc().tsc
        now_up = tsc_time.get_kernel_usec()
        now_p = now_up / 1000000
        now_fp = float(now_up) / 1000000

        # Conversion looses some accuracy.
        ticks_close = (tsc_time.ticks_per_sec / 10.0)
        p_close = 0
        up_close = 100000
        fp_close = 0.1

        self._assert_close(now_t,
                           tsc_time.usec_to_ticks(now_up),
                           ticks_close
                           )
        self._assert_close(now_up,
                           tsc_time.ticks_to_usec(now_t),
                           up_close
                           )
        self._assert_close(now_t,
                           tsc_time.usec_to_ticks_safe(now_up),
                           ticks_close
                           )
        self._assert_close(now_up,
                           tsc_time.ticks_to_usec_safe(now_t),
                           up_close
                           )
        self._assert_close(now_t,
                           tsc_time.sec_to_ticks(now_p),
                           tsc_time.ticks_per_sec
                           )
        self._assert_close(now_p,
                           tsc_time.ticks_to_sec(now_t),
                           p_close
                           )
        self._assert_close(now_fp,
                           tsc_time.ticks_to_fsec(now_t),
                           fp_close
                           )
        self._assert_close(now_t,
                           tsc_time.fsec_to_ticks(now_fp),
                           ticks_close
                           )
Ejemplo n.º 2
0
    def test_raw_conversion(self):
        now_t = tsc_time.now_tsc().tsc
        now_up = tsc_time.get_kernel_usec()
        now_p = now_up / 1000000
        now_fp = float(now_up) / 1000000

        # Conversion looses some accuracy.
        ticks_close = (tsc_time.ticks_per_sec / 10.0)
        p_close = 0
        up_close = 100000
        fp_close = 0.1

        self._assert_close(now_t, tsc_time.usec_to_ticks(now_up), ticks_close)
        self._assert_close(now_up, tsc_time.ticks_to_usec(now_t), up_close)
        self._assert_close(now_t, tsc_time.usec_to_ticks_safe(now_up),
                           ticks_close)
        self._assert_close(now_up, tsc_time.ticks_to_usec_safe(now_t),
                           up_close)
        self._assert_close(now_t, tsc_time.sec_to_ticks(now_p),
                           tsc_time.ticks_per_sec)
        self._assert_close(now_p, tsc_time.ticks_to_sec(now_t), p_close)
        self._assert_close(now_fp, tsc_time.ticks_to_fsec(now_t), fp_close)
        self._assert_close(now_t, tsc_time.fsec_to_ticks(now_fp), ticks_close)
Ejemplo n.º 3
0
def get_usec():
    """This is for backwards compatibility and should not be used."""
    return tsc_time.ticks_to_usec(get_now())
Ejemplo n.º 4
0
def get_usec():
    """This is for backwards compatibility and should not be used."""
    return tsc_time.ticks_to_usec(get_now())