×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    6

    What is the time granularity in Pys60?

    time.time() only give me second.
    Is it possible to get millisecond from anywhere?
    Thanks a lot

  2. #2
    Registered User
    Join Date
    Mar 2007
    Location
    Paris, France
    Posts
    78

    Re: What is the time granularity in Pys60?

    Quote Originally Posted by ericliquid View Post
    time.time() only give me second.
    Is it possible to get millisecond from anywhere?
    Thanks a lot
    Hi,

    I had the same problem, I used a little C++ code compiled as a Python module to get more precise time. But I don't know how accurate it is; if Python does not return more precise time it *may* not be enough accurate to return valid data (Has anyone more informations?)

    Code available in this file : https://air.mosomuso.com/pubhg/pyext...p;style=gitweb

    Regards,
    Christophe Berger

  3. #3
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: What is the time granularity in Pys60?

    Quote Originally Posted by ericliquid View Post
    time.time() only give me second.
    Is it possible to get millisecond from anywhere?
    Try time.clock(). It returns seconds since last reboot with some decimals.

    help(time.clock) says:
    Quote Originally Posted by help(time.clock)
    Return the CPU time or real time since the start of the process or since the first call to clock(). This has as much precision as the system records.
    I don't know how much precision Symbian system has.

  4. #4
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: What is the time granularity in Pys60?

    hello ,

    You can find more info here

    miso module provide a nice tick count function :

    Code:
    import miso,e32
    
    print miso.tick_count()
    e32.ao_sleep(1)
    print miso.tick_count()
    e32.ao_sleep(1)
    print miso.tick_count()
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  5. #5
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: What is the time granularity in Pys60?

    hello again ,

    I have tried this snippet with miso.tick_count() and found that precision is only 1/64 sec on a E61 (3rd edition)

    Try it yourself :
    Code:
    import miso,e32
    
    b=miso.tick_count()
    e=miso.tick_count()
    print e-b
    print miso.tick_count()
    print miso.tick_count()
    
    
    print miso.tick_count()
    e32.ao_sleep(1)
    print miso.tick_count()
    e32.ao_sleep(1)
    print miso.tick_count()
    
    b1=miso.tick_count()
    e32.ao_sleep(1)
    e1=miso.tick_count()
    e32.ao_sleep(1)
    e2=miso.tick_count()
    
    
    print e1-b1
    print e2-e1
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  6. #6
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: What is the time granularity in Pys60?

    Quote Originally Posted by bergerc View Post
    Hi,

    I had the same problem, I used a little C++ code compiled as a Python module to get more precise time. But I don't know how accurate it is; if Python does not return more precise time it *may* not be enough accurate to return valid data (Has anyone more informations?)

    Code available in this file : https://air.mosomuso.com/pubhg/pyext...p;style=gitweb

    Regards,
    hello ,

    I try your phone_time() function with the same snippet it seems more precise than miso (1/64 sec) !

    Code:
    import gps_location,e32
    
    def format_time(time):
      return int("%2d%2d%6d"%(time[4],time[5],time[6]))
    
    b=format_time(gps_location.phone_time())
    e=format_time(gps_location.phone_time())
    print e-b
    print gps_location.phone_time()[6]
    print gps_location.phone_time()[6]
    
    
    print format_time(gps_location.phone_time())
    e32.ao_sleep(1)
    print format_time(gps_location.phone_time())
    e32.ao_sleep(1)
    print format_time(gps_location.phone_time())
    
    b1=format_time(gps_location.phone_time())
    e32.ao_sleep(1)
    e1=format_time(gps_location.phone_time())
    e32.ao_sleep(1)
    e2=format_time(gps_location.phone_time())
    
    
    print e1-b1
    print e2-e1
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    22

    Re: What is the time granularity in Pys60?

    Is this really the only way to get more granularity - to use C++ code?

  8. #8
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: What is the time granularity in Pys60?

    Quote Originally Posted by hyon View Post
    Is this really the only way to get more granularity - to use C++ code?
    What was wrong with aaaaapo's suggestion of using time.clock()? It's as accurate as you can get from the hardware. On my device it seems to provide accuracy to the nearest millisecond.

    I use code like this in AyIX:

    Code:
    import time
    
    # Run this once when your program starts
    CLOCK_OFFSET = int(round(time.time())) - int(round(time.clock()))
    
    # Call this to return UNIX timestamp to nearest millisecond
    def getTime():
        return time.clock() + CLOCK_OFFSET

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    22

    Smile Re: What is the time granularity in Pys60?

    Quote Originally Posted by aya42 View Post
    What was wrong with aaaaapo's suggestion of using time.clock()? It's as accurate as you can get from the hardware. On my device it seems to provide accuracy to the nearest millisecond.

    I use code like this in AyIX:

    Code:
    import time
    
    # Run this once when your program starts
    CLOCK_OFFSET = int(round(time.time())) - int(round(time.clock()))
    
    # Call this to return UNIX timestamp to nearest millisecond
    def getTime():
        return time.clock() + CLOCK_OFFSET
    That solved my problem. Thank you!

Similar Threads

  1. CPU time and time execution of a function
    By olfasupcom in forum Symbian
    Replies: 5
    Last Post: 2007-06-12, 14:12
  2. how to distribute pys60 based apps?
    By chall3ng3r in forum Symbian
    Replies: 4
    Last Post: 2007-03-27, 14:13
  3. Bizarre calendar/time zone change handling in Nokia 9500
    By noetus in forum General Development Questions
    Replies: 0
    Last Post: 2005-09-19, 19:27
  4. Log time bug on 3650. Help me please.
    By hemenkap in forum General Development Questions
    Replies: 2
    Last Post: 2005-06-30, 07:18
  5. SMS time stamp format with time zone parameter?
    By turunhe in forum General Messaging
    Replies: 1
    Last Post: 2002-06-11, 07:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×