Ejemplo n.º 1
0
    def test_from(self):
        now_tsc = tsc_time.now_tsc()

        self.assertEqual(now_tsc.tsc, tsc_time.TSC_from_ticks(now_tsc.tsc).tsc)
        self.assertEqual(
            tsc_time.sec_to_ticks(now_tsc.as_posix_sec()),
            tsc_time.TSC_from_posix_sec(now_tsc.as_posix_sec()).tsc)
        self.assertEqual(
            tsc_time.usec_to_ticks(now_tsc.as_posix_usec()),
            tsc_time.TSC_from_posix_usec(now_tsc.as_posix_usec()).tsc)
        self.assertEqual(
            tsc_time.fsec_to_ticks(now_tsc.as_posix_fsec()),
            tsc_time.TSC_from_posix_fsec(now_tsc.as_posix_fsec()).tsc)

        self.assertEqual(now_tsc.tsc,
                         tsc_time.Posix_from_ticks(now_tsc.tsc).tsc)
        self.assertEqual(
            tsc_time.sec_to_ticks(now_tsc.as_posix_sec()),
            tsc_time.Posix_from_posix_sec(now_tsc.as_posix_sec()).tsc)
        self.assertEqual(
            tsc_time.usec_to_ticks(now_tsc.as_posix_usec()),
            tsc_time.Posix_from_posix_usec(now_tsc.as_posix_usec()).tsc)
        self.assertEqual(
            tsc_time.fsec_to_ticks(now_tsc.as_posix_fsec()),
            tsc_time.Posix_from_posix_fsec(now_tsc.as_posix_fsec()).tsc)

        self.assertEqual(now_tsc.tsc,
                         tsc_time.uPosix_from_ticks(now_tsc.tsc).tsc)
        self.assertEqual(
            tsc_time.sec_to_ticks(now_tsc.as_posix_sec()),
            tsc_time.uPosix_from_posix_sec(now_tsc.as_posix_sec()).tsc)
        self.assertEqual(
            tsc_time.usec_to_ticks(now_tsc.as_posix_usec()),
            tsc_time.uPosix_from_posix_usec(now_tsc.as_posix_usec()).tsc)
        self.assertEqual(
            tsc_time.fsec_to_ticks(now_tsc.as_posix_fsec()),
            tsc_time.uPosix_from_posix_fsec(now_tsc.as_posix_fsec()).tsc)

        self.assertEqual(now_tsc.tsc,
                         tsc_time.fPosix_from_ticks(now_tsc.tsc).tsc)
        self.assertEqual(
            tsc_time.sec_to_ticks(now_tsc.as_posix_sec()),
            tsc_time.fPosix_from_posix_sec(now_tsc.as_posix_sec()).tsc)
        self.assertEqual(
            tsc_time.usec_to_ticks(now_tsc.as_posix_usec()),
            tsc_time.fPosix_from_posix_usec(now_tsc.as_posix_usec()).tsc)
        self.assertEqual(
            tsc_time.fsec_to_ticks(now_tsc.as_posix_fsec()),
            tsc_time.fPosix_from_posix_fsec(now_tsc.as_posix_fsec()).tsc)
Ejemplo n.º 2
0
    def test_from(self):
        now_tsc = tsc_time.now_tsc()

        self.assertEqual(now_tsc.tsc,
                         tsc_time.TSC_from_ticks(now_tsc.tsc).tsc)
        self.assertEqual(tsc_time.sec_to_ticks(now_tsc.as_posix_sec()),
                         tsc_time.TSC_from_posix_sec(now_tsc.as_posix_sec()).tsc)
        self.assertEqual(tsc_time.usec_to_ticks(now_tsc.as_posix_usec()),
                         tsc_time.TSC_from_posix_usec(now_tsc.as_posix_usec()).tsc)
        self.assertEqual(tsc_time.fsec_to_ticks(now_tsc.as_posix_fsec()),
                         tsc_time.TSC_from_posix_fsec(now_tsc.as_posix_fsec()).tsc)

        self.assertEqual(now_tsc.tsc,
                         tsc_time.Posix_from_ticks(now_tsc.tsc).tsc)
        self.assertEqual(tsc_time.sec_to_ticks(now_tsc.as_posix_sec()),
                         tsc_time.Posix_from_posix_sec(now_tsc.as_posix_sec()).tsc)
        self.assertEqual(tsc_time.usec_to_ticks(now_tsc.as_posix_usec()),
                         tsc_time.Posix_from_posix_usec(now_tsc.as_posix_usec()).tsc)
        self.assertEqual(tsc_time.fsec_to_ticks(now_tsc.as_posix_fsec()),
                         tsc_time.Posix_from_posix_fsec(now_tsc.as_posix_fsec()).tsc)

        self.assertEqual(now_tsc.tsc,
                         tsc_time.uPosix_from_ticks(now_tsc.tsc).tsc)
        self.assertEqual(tsc_time.sec_to_ticks(now_tsc.as_posix_sec()),
                         tsc_time.uPosix_from_posix_sec(now_tsc.as_posix_sec()).tsc)
        self.assertEqual(tsc_time.usec_to_ticks(now_tsc.as_posix_usec()),
                         tsc_time.uPosix_from_posix_usec(now_tsc.as_posix_usec()).tsc)
        self.assertEqual(tsc_time.fsec_to_ticks(now_tsc.as_posix_fsec()),
                         tsc_time.uPosix_from_posix_fsec(now_tsc.as_posix_fsec()).tsc)

        self.assertEqual(now_tsc.tsc,
                         tsc_time.fPosix_from_ticks(now_tsc.tsc).tsc)
        self.assertEqual(tsc_time.sec_to_ticks(now_tsc.as_posix_sec()),
                         tsc_time.fPosix_from_posix_sec(now_tsc.as_posix_sec()).tsc)
        self.assertEqual(tsc_time.usec_to_ticks(now_tsc.as_posix_usec()),
                         tsc_time.fPosix_from_posix_usec(now_tsc.as_posix_usec()).tsc)
        self.assertEqual(tsc_time.fsec_to_ticks(now_tsc.as_posix_fsec()),
                         tsc_time.fPosix_from_posix_fsec(now_tsc.as_posix_fsec()).tsc)
Ejemplo n.º 3
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.º 4
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)