Getting time in microseconds

With the class java.lang.System you can have time in milli seconds via the function getTimeMillis().
I should be very helpfull to have another function like this getTimeMicros() that returns time in microseconds.
Because in some tests I made I did not have enough precision with time in milliseconds. So I hope for the JDK 1.5.1 this function will be created.
Thanks a lot.

I was requesting precision in microseconds but I was
not expecting to have it in nanos ! It's wonderlfull
It could not be more precise anymore !Well, this makes sense only if the underlying OS
supports it. Don't expect nanosecond accuracy unless
you actually test it on the platform you're going to
run it on.Moreover it might not be 1 nano either. Just as millis are not necessarily 1 milli.

Similar Messages

  • Get time in microseconds

    i want to time algorithms and would like to time them in microseconds.
    I don't know how do that.
    thanks

    i want to time algorithms and would like to time them
    in microseconds.
    I don't know how do that.
    thanksJava doesn't provide that kind of time-resolution. Your best bet is to run each algoritm many times in a loop so the total time becomes seconds. Then you divide by the number of repeats and get the average time for your algoritm -:)
    This has another advantage. The optimizations done by the Java runtime system may take some runs to kick in and by repeating the algoritms many times the "warm up" time will be averaged out.
    But be careful if your algoritms allocate many objects on the stack so you aren't actually measuring the garbage collectors performance.

  • How can I get the time in Microsecond with JNI ?

    How can I get the time in Microsecond with JNI ?

    JNIEXPORT jdouble JNICALL Java_Win32Native_queryPerformanceFrequency (JNIEnv *env, jobject obj) {
         LARGE_INTEGER lFrequency;
         ::QueryPerformanceFrequency(&lFrequency);
         return (jdouble)lFrequency.QuadPart;
    JNIEXPORT jdouble JNICALL Java_Win32Native_queryPerformanceCounter (JNIEnv *env, jobject obj) {
         LARGE_INTEGER lpCounter;
         ::QueryPerformanceCounter(&lpCounter);
         return (jdouble)lpCounter.QuadPart;

  • Current time in microseconds

    For one of my programs i want to find the current time in microseconds. How do i get this in Java?

    The server makes the OS calls that hook into the system processor cycle count,....
    Java doesn't directly provide this functionality.Which brings up an interesting question/point (I think).
    Since Java provides an sql.TimeStamp class to map to an sql database supporting nanos, how does Java instantiate this class as far as nanos are concerned? Unless the only thing its good for is for READING sql TIMESTAMP values.
    My understanding of this is important as it can impact my db design. I would rather have my ejb's create this data in the j2ee server, when doing sql INSERT's, rather than having the db itself do the TIMESTAMP with a trigger (for a variety of reasons, including cache maintenance). But if the nanos are all zero(!)...well, need to use a trigger.
    Thanks
    -nat

  • Retrieve Computer time in microsecond

    to retrieve computer time i use the function System.currentTimeMillis() but i need the time in microsecond. how could i get that?

    <snip>
    Java 1.5 added nanosecond methods for hardware/OS
    combinations that can support it.Which at current includes none at all :)<snip>
    Are you saying that System.nanoTime() isn't supported at the present time?
    That's not correct - I am running a 3 GB Pentium 4, a relatively recent GigaByte m/b and XP Pro, and get very good microsecond and submicrosecond results from the method.
    I executed 2 consecutuive calls to the method, like so
    startTime = System.nanoTime();
    estimatedTime = System.nanoTime() - startTime;and averaged 100 repetitions.
    Results vary with the manner in which the jvm is executed. Here's a summary of results, to give a feel for what's possible.
    Program Execution From        Nanoseconds (average)
    Commandline                     1300
    CrimsonEditor                    500
    jEdit                            700
    NetBeans IDE 4.1                1050So, depending on the method of execution, nanosecond precision ranges from 500 to 1300 (0.5 microsecond to 1.3 microsecond). Accuracy (repeatability) is not as good - there are outliers in the individual times, probably due to Garbage Collections. However excluding those outliers, times appear reasonably repeatable.

  • Time in Microsecond

    Hello Friends,
    Is it possible to get time in micro second in Java? If yes, can anyone tell how? My email is [email protected]
    Thanks in advance,
    gaurang.

    i think there is no chance to do it, cos java is to slow for this. if a microsecond is over, the javainterpeter is just not at the end of the line, where you want to get microsecond
    regards

  • Having trouble getting Time Machine to back up my external hard drive.  Any suggestions?

    I'm running Mountain Lion on my iMac and I've been using Time Machine to back it up to my Time Capsule.  Recently, the iMac's hard drive filled up, so I moved my iTunes library to a new Airport Time Capsule.  But I can't seem to get Time Machine to include the new Airport Time Capsule in its back up. 
    The only suggestion I can find is to make sure it's not excluded in the Time Machine options, and I can see that nothing is excluded.  However, when I go into Time Machine, the Airport Time Capsule is greyed out in the Finder window.
    Anyone have any ideas?  Thanks in advance, I'm a little nervous about having my iTunes library hanging out there without a back up...

    Linc Davis wrote:
    You can't back up the internal drive of the Time Capsule with Time Machine. It will only back up locally attached storage devices, not network devices. There's no way around it. You may be able to back up the TC with third-party software such as "Carbon Copy Cloner," but it will be very slow. The internal drive of the TC is only suitable for use as a backup device. It's not suited for storing original data.
    yeah well you can use the external hard drive as a data extension to the time capsule internal hard drive. like a RAID in effect...

  • Performance issue in Report (getting time out error)

    Hi experts,
    I am doing Performance for a Report (getting time out error)
    Please see the code below and .
    while looping internal table IVBAP after 25 minutes its showing  time out error at this poit ->
    SELECT MAX( ERDAT ) .
    please send alternate code for this .
    Advance thanks
    from
    Nagendra
    Get Sales Order Details
    CLEAR IVBAP.
    REFRESH IVBAP.
    SELECT VBELN POSNR MATNR NETWR KWMENG WERKS FROM VBAP
       INTO CORRESPONDING FIELDS OF TABLE IVBAP
         FOR ALL ENTRIES IN IVBAK
           WHERE VBELN =  IVBAK-VBELN
           AND   MATNR IN Z_MATNR
           AND   WERKS IN Z_WERKS
           AND   ABGRU = ' '.
    Check for Obsolete Materials - Get Product Hierarhy/Mat'l Description
      SORT IVBAP BY MATNR WERKS.
      CLEAR: WK_MATNR, WK_WERKS, WK_PRDHA, WK_MAKTX,
             WK_BLOCK, WK_MMSTA, WK_MSTAE.
      LOOP AT IVBAP.
          CLEAR WK_INVDATE.                                   "I6677.sn
          SELECT MAX( ERDAT ) FROM VBRP INTO WK_INVDATE WHERE
          AUBEL EQ IVBAP-VBELN AND
          AUPOS EQ IVBAP-POSNR.
          IF SY-SUBRC = 0.
              MOVE WK_INVDATE TO IVBAP-INVDT.
              MODIFY IVBAP.
          ENDIF.                                               "I6677.e n
          SELECT SINGLE * FROM MBEW WHERE             "I6759.sn
          MATNR EQ IVBAP-MATNR AND
          BWKEY EQ IVBAP-WERKS AND
          BWTAR EQ SPACE.
          IF SY-SUBRC = 0.
             MOVE MBEW-STPRS TO IVBAP-STPRS.
             IVBAP-TOT = MBEW-STPRS * IVBAP-KWMENG.
             MODIFY IVBAP.
          ENDIF.                                      "I6759.en
        IF IVBAP-MATNR NE WK_MATNR OR IVBAP-WERKS NE WK_WERKS.
          CLEAR: WK_BLOCK, WK_MMSTA, WK_MSTAE, WK_PRDHA, WK_MAKTX.
          MOVE IVBAP-MATNR TO WK_MATNR.
          MOVE IVBAP-WERKS TO WK_WERKS.
          SELECT SINGLE MMSTA FROM MARC INTO MARC-MMSTA
            WHERE MATNR = WK_MATNR
            AND   WERKS = WK_WERKS.
          IF NOT MARC-MMSTA IS INITIAL.
            MOVE '*' TO WK_MMSTA.
          ENDIF.
          SELECT SINGLE LVORM PRDHA MSTAE MSTAV FROM MARA
            INTO (MARA-LVORM, MARA-PRDHA, MARA-MSTAE, MARA-MSTAV)
            WHERE MATNR = WK_MATNR.
          IF ( NOT MARA-MSTAE IS INITIAL ) OR
             ( NOT MARA-MSTAV IS INITIAL ) OR
             ( NOT MARA-LVORM IS INITIAL ).
             MOVE '*' TO WK_MSTAE.
          ENDIF.
          MOVE MARA-PRDHA TO WK_PRDHA.
          SELECT SINGLE MAKTX FROM MAKT INTO WK_MAKTX
            WHERE MATNR = WK_MATNR
              AND SPRAS = SY-LANGU.
        ENDIF.
        IF Z_BLOCK EQ 'B'.
          IF WK_MMSTA EQ ' ' AND WK_MSTAE EQ ' '.
            DELETE IVBAP.
            CONTINUE.
          ENDIF.
        ELSEIF Z_BLOCK EQ 'U'.
          IF WK_MMSTA EQ '' OR WK_MSTAE EQ ''.
            DELETE IVBAP.
            CONTINUE.
          ENDIF.
        ELSE.
          IF WK_MMSTA EQ '' OR WK_MSTAE EQ ''.
            MOVE '*' TO WK_BLOCK.
          ENDIF.
        ENDIF.
        IF WK_PRDHA IN Z_PRDHA.                                    "I4792
          MOVE WK_BLOCK TO IVBAP-BLOCK.
          MOVE WK_PRDHA TO IVBAP-PRDHA.
          MOVE WK_MAKTX TO IVBAP-MAKTX.
          MODIFY IVBAP.
        ELSE.                                                     "I4792
          DELETE IVBAP.                                           "I4792
        ENDIF.                                                    "I4792
        IF NOT Z_ALNUM[] IS INITIAL.                              "I9076
          SELECT SINGLE * FROM MAEX                               "I9076
            WHERE MATNR = IVBAP-MATNR                             "I9076
              AND ALNUM IN Z_ALNUM.                               "I9076
          IF SY-SUBRC <> 0.                                       "I9076
            DELETE IVBAP.                                         "I9076
          ENDIF.                                                  "I9076
        ENDIF.                                                    "I9076
      ENDLOOP.

    Hi Nagendra!
    Get Sales Order Details
    CLEAR IVBAP.
    REFRESH IVBAP.
    check ivbak is not initial
    SELECT VBELN POSNR MATNR NETWR KWMENG WERKS FROM VBAP
    INTO CORRESPONDING FIELDS OF TABLE IVBAP
    FOR ALL ENTRIES IN IVBAK
    WHERE VBELN = IVBAK-VBELN
    AND MATNR IN Z_MATNR
    AND WERKS IN Z_WERKS
    AND ABGRU = ' '.
    Check for Obsolete Materials - Get Product Hierarhy/Mat'l Description
    SORT IVBAP BY MATNR WERKS.
    CLEAR: WK_MATNR, WK_WERKS, WK_PRDHA, WK_MAKTX,
    WK_BLOCK, WK_MMSTA, WK_MSTAE.
    avoid select widin loop. instead do selection outside loop.u can use read statement......and then loop if required.
    LOOP AT IVBAP.
    CLEAR WK_INVDATE. "I6677.sn
    SELECT MAX( ERDAT ) FROM VBRP INTO WK_INVDATE WHERE
    AUBEL EQ IVBAP-VBELN AND
    AUPOS EQ IVBAP-POSNR.
    IF SY-SUBRC = 0.
    MOVE WK_INVDATE TO IVBAP-INVDT.
    MODIFY IVBAP.
    ENDIF. "I6677.e n
    SELECT SINGLE * FROM MBEW WHERE "I6759.sn
    MATNR EQ IVBAP-MATNR AND
    BWKEY EQ IVBAP-WERKS AND
    BWTAR EQ SPACE.
    IF SY-SUBRC = 0.
    MOVE MBEW-STPRS TO IVBAP-STPRS.
    IVBAP-TOT = MBEW-STPRS * IVBAP-KWMENG.
    MODIFY IVBAP.
    ENDIF. "I6759.en
    IF IVBAP-MATNR NE WK_MATNR OR IVBAP-WERKS NE WK_WERKS.
    CLEAR: WK_BLOCK, WK_MMSTA, WK_MSTAE, WK_PRDHA, WK_MAKTX.
    MOVE IVBAP-MATNR TO WK_MATNR.
    MOVE IVBAP-WERKS TO WK_WERKS.
    SELECT SINGLE MMSTA FROM MARC INTO MARC-MMSTA
    WHERE MATNR = WK_MATNR
    AND WERKS = WK_WERKS.
    IF NOT MARC-MMSTA IS INITIAL.
    MOVE '*' TO WK_MMSTA.
    ENDIF.
    SELECT SINGLE LVORM PRDHA MSTAE MSTAV FROM MARA
    INTO (MARA-LVORM, MARA-PRDHA, MARA-MSTAE, MARA-MSTAV)
    WHERE MATNR = WK_MATNR.
    IF ( NOT MARA-MSTAE IS INITIAL ) OR
    ( NOT MARA-MSTAV IS INITIAL ) OR
    ( NOT MARA-LVORM IS INITIAL ).
    MOVE '*' TO WK_MSTAE.
    ENDIF.
    MOVE MARA-PRDHA TO WK_PRDHA.
    SELECT SINGLE MAKTX FROM MAKT INTO WK_MAKTX
    WHERE MATNR = WK_MATNR
    AND SPRAS = SY-LANGU.
    ENDIF.
    IF Z_BLOCK EQ 'B'.
    IF WK_MMSTA EQ ' ' AND WK_MSTAE EQ ' '.
    DELETE IVBAP.
    CONTINUE.
    ENDIF.
    ELSEIF Z_BLOCK EQ 'U'.
    IF WK_MMSTA EQ '' OR WK_MSTAE EQ ''.
    DELETE IVBAP.
    CONTINUE.
    ENDIF.
    ELSE.
    IF WK_MMSTA EQ '' OR WK_MSTAE EQ ''.
    MOVE '*' TO WK_BLOCK.
    ENDIF.
    ENDIF.
    IF WK_PRDHA IN Z_PRDHA. "I4792
    MOVE WK_BLOCK TO IVBAP-BLOCK.
    MOVE WK_PRDHA TO IVBAP-PRDHA.
    MOVE WK_MAKTX TO IVBAP-MAKTX.
    MODIFY IVBAP.
    ELSE. "I4792
    DELETE IVBAP. "I4792
    ENDIF. "I4792
    IF NOT Z_ALNUM[] IS INITIAL. "I9076
    SELECT SINGLE * FROM MAEX "I9076
    WHERE MATNR = IVBAP-MATNR "I9076
    AND ALNUM IN Z_ALNUM. "I9076
    IF SY-SUBRC 0. "I9076
    DELETE IVBAP. "I9076
    ENDIF. "I9076
    ENDIF. "I9076
    endloop.
    U have used many select queries widin loop-endloop which is a big hindrance as far as performance is concerned.Avoid such practice.
    Thanks
    Deepika

  • I am trying to update my time machine backup on time capsule, but time machine keeps trying to create an entirely new backup (evidenced by the 200GB backup size). How can I get time machine to modify my old backup rather than create a new one?

    I am trying to update my time machine backup on time capsule, but time machine keeps trying to create an entirely new backup (evidenced by the 200GB backup size). How can I get time machine to modify my old backup rather than create a new one?

    It must have found the old backup corrupt.. so you will more than likely have little choice. You can archive off the old backup if it is still useful.
    You can also verify it. See A5 http://pondini.org/TM/Troubleshooting.html
    He also has some info on this problem. eg C13.

  • I can't get Time Machine to recognize my external hard drive.

    I bought a new hard drive when we moved last September and it backed up my files once or twice.  Now I cannot get Time Machine to recognize it at all.
    I have tried to format it with Disc Utility and only get an error message:  Error: Unable to unmount volume for repair.  Is there anything I can do with this?

    Is the drive showing up in finder?
    Did you have it working then upgraded to Yosemite??
    Amongst the many many bug in yosemite is a bug/s to do with no longer being able to use USB drive.
    Did you try the fixes here.
    OS X Yosemite: If a USB device isn’t working
    Personally I would plug it into a computer running anything except Yosemite and you might find it works perfectly.. the issue then is not the drive.

  • Getting Time Machine back up to a Sparsebundle on external HDD (Drobo)

    Hey,
    I've been chasing this issue around for a while but can't seem to find the answer.
    There are a lot of resources out there describing how to get your Mac to backup to a Sparsebundle on a NAS, and more resources telling you how to write protect the Info.plist file so that Mac OS doesn't resize the image to take up all of your NAS.
    However I've got a Drobo connected directly to my Mac Mini. The Drobo pretends to have a 16TB drive so that you can add storage as and when you need it.
    I am already using it to back up my MBP over the network to a Sparsebundle and until recently I was using the same scheme (a size limited sparsebundle) to back up the Mac Mini that the Drobo is connected to.
    I achieved this by following the excellent directions on http://anitechtalk.wordpress.com/2010/07/19/time-machine-dns323/ (one of the only sites that mentions the new way that Apple handles Time Machine Sparsebundles)
    However this has recently stopped working and no matter what I do I still cannot get my Mac to see the Sparsebundle as a TimeMachine aware 'drive'- instead it just backs up to the root of the '16TB' Drobo- and at some point it's going to get rather full.
    Argh.
    (And yes, I know that the other solution is to re-partition my Drobo to have a small partition at the start of the disk for Time Machine to use- but it's too late for that as I've already got 1.85TB of data on there and I doubt that I can re-partition that without losing all of the data.)
    Can anyone help me get Time Machine to accept my Sparsebundle as a 'disk' that it can backup to?
    Thanks in advance.

    Thank you for the video link. I did it pretty much exactly the way the young man explained. The one thing I didn't do was click "customize" as he does and unclick the multiple language support and he also clicks "rosetta" to support older programs. I wonder if that's the issue? The guys at Macmall told me that I would need to update the o.s. before I restored. I did that originally but have since (as mentioned before) erased the main drive. I noticed that when he does his install, his external drive does not show up on the list in which you want to install the o.s. on... should I unplug my external? I'm just trying to look at ever detail. I know the recovery file is there. The one thing it (the external) did say before I started posting here was "in progress". I'm not sure what that means? I promise I'm not an idiot. I consider myself an above average user. I usually help other that have issues... but I've yet to restore from a Time Machine back-up and I'm looking forward to learning how to do it.... the right way. I appreciate all of the advice. I have some pretty important files on my external back-up. I am really hoping that this is possible. I'm beginning to think the external is where the issue lies. The "in progress" next to the file name concerns me. I know there's a lot of data on the drive because it's nearly half full. So there's stuff there....
    Deep breath in...... reeee laaaaaaaxxxx

  • How can I get Time Machine to back up an external hard drive (iPhotos) that is attached to airport extreme base station. Note: Time machine is usb to macbook pro and external drive with iphotos is usb to airport extreme base station. Help please. Thanks!

    How can I get Time Machine to back up an external hard drive (iPhotos) that is attached to airport extreme base station. Note: Time machine is usb to macbook pro and external drive with iphotos is usb to airport extreme base station. Help please. Thanks!

    Once you have the drive connected to your Mac, click System Preferences (gear icon) on the dock
    Click Time Machine
    Click Options
    Be default, the hard drive will be Excluded from backups. Click the drive to highlight it, then click the "-" (minus) button at the bottom of the list to remove the drive from Excluded items.
    The drive will be backed up on the next Time Machine pass
    Everything above assumes that the hard drive has been formatted in Mac OS Extended (Journaled) as Time Machine will only backup drives in that format.

  • My time machine backup external hard drive has failed.  I have a newer external drive already connected to my MAC but can't figure out how to get Time Machine to set up on it?

    My time machine backup external hard drive has failed.  I have a newer external drive already connected to my MAC but can't figure out how to get Time Machine to set up on it

    http://pondini.org/TM/21.html

  • Cannot get Time Machine to work

    I just installed Leopard on my Power MacG4. I can't get Time Machine to work. I have gone to Utilities and repaired partitions twice. That doesn't seem to be the problem. I have no idea what to do. Any ideas?

    Pondini wrote:
    Maybe, maybe not. Via Disk Utility, when you click the first line for the drive (Make, Size), does it show the +Apple Partition Map+ down near the bottom, and when you click the second line, show +Mac OS Extended (journaled)?+ If not, that's at least part of the problem.
    There should be better messages in your logs. Download the +Time Machine Buddy+ widget. It shows the messages from your logs for one TM backup run at a time, in a small window. Navigate to the failed backup, then copy and post the messages here (be sure to get them all, as sometimes they overflow the small window).
    Checked the disk utility and everything shows as you say it should. Here's the log:
    Starting standard backup
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Backup content size: 35.1 GB excluded items size: 144 KB for volume Macintosh HD
    No pre-backup thinning needed: 42.14 GB requested (including padding), 931.15 GB available
    Error: (-36) SrcErr:NO Copying /Adobe Acrobat 3.0/Acrobat™ Distiller™ 3.01 to /Volumes/Time Machine Backups/Backups.backupdb/Kathy Miller’s Computer/2009-03-08-153448.inProgress/62856C2A-1F0A-438D-925C-B5A18D6E5416/Maci ntosh HD/Adobe Acrobat 3.0
    Stopping backup.
    Error: (-8062) SrcErr:NO Copying /Adobe Acrobat 3.0/Acrobat™ Distiller™ 3.01 to /Volumes/Time Machine Backups/Backups.backupdb/Kathy Miller’s Computer/2009-03-08-153448.inProgress/62856C2A-1F0A-438D-925C-B5A18D6E5416/Maci ntosh HD/Adobe Acrobat 3.0
    Copied 0 files (2.7 MB) from volume Macintosh HD.
    Copy stage failed with error:11
    Backup failed with error: 11

  • I am running 10.7.5 and getting Time Machine error The backup disk image "/Volumes/Data/Kathy P's MacBook.sparsebundle" is already in use. what do i do now?

    i am running 10.7.5 on an older MacBook and getting Time Machine error The backup disk image “/Volumes/Data/Kathy P’s MacBook.sparsebundle” is already in use. what do i do now?

    See Pondini's TM FAQs, for starters.

Maybe you are looking for

  • Text Appearing as 1-Pixel-Sized Boxes in CS2

    Greetings, I'm having a problem with text inside Photoshop CS2. I've never had this problem before so I'm not sure what's causing it or how to fix it-- obviously. I first noticed this problem when I was doing some work in Photoshop earlier today. I w

  • "iTunes:iTunes.exe - Corrupt File" help

    When I hook up my iPod to my computer, I run Windows XP Professional on a Dell, I get a message on the bottom righ that reads iTunes:iTunes.exe - Corrupt File The file or directory \iPod_Control\Device\SysInfo is currupt and unreadable. Please run th

  • I can't open dmg files anymore

    I JUST got this problem. I have been using my mac for a couple of years now. My Mac is a Macbook Pro, Version 10.7.2 (Lion) Recently, I have been unable to open Dmg files, whenever I double click it, I get a message saying: "Warning, the following di

  • Black lined 'ghost box' is suddenly around every text box, functions, etc.

    I have OS 10.4.11. I had Safari/Firefox open. I was on Ebay, I copied a link to forward.  I opened Entourage to send the link via Email, suddenly I had a black lined box around all functions, etc. and under the Apple Menu, shutdown, restart and logou

  • SVG and SVG states support.

    I would like to see full support on SVG's. SVG's with hyperlinks that allow for state changes (normal/mouse over/mouse down/active).