예제 #1
0
    def test_time_methods(self):
        t = tsc_time.now_tsc()
        now_up = tsc_time.get_kernel_usec()
        now_fp = float(now_up) / 1000000

        self.assertEqual(time.ctime(now_fp), t.ctime())
        self.assertEqual(time.localtime(now_fp), t.localtime())
        self.assertEqual(time.gmtime(now_fp), t.gmtime())
        self.assertEqual(time.strftime('%a %b %d %H:%M:%S %Y', time.localtime(now_fp)),
                         t.mkstr_local('%a %b %d %H:%M:%S %Y'))
        self.assertEqual(time.strftime('%a %b %d %H:%M:%S %Y', time.gmtime(now_fp)),
                         t.mkstr_utc('%a %b %d %H:%M:%S %Y'))
예제 #2
0
    def test_time_methods(self):
        t = tsc_time.now_tsc()
        now_up = tsc_time.get_kernel_usec()
        now_fp = float(now_up) / 1000000

        self.assertEqual(time.ctime(now_fp), t.ctime())
        self.assertEqual(time.localtime(now_fp), t.localtime())
        self.assertEqual(time.gmtime(now_fp), t.gmtime())
        self.assertEqual(
            time.strftime('%a %b %d %H:%M:%S %Y', time.localtime(now_fp)),
            t.mkstr_local('%a %b %d %H:%M:%S %Y'))
        self.assertEqual(
            time.strftime('%a %b %d %H:%M:%S %Y', time.gmtime(now_fp)),
            t.mkstr_utc('%a %b %d %H:%M:%S %Y'))
예제 #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
                           )
예제 #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)