Measuring time in smaller unit than millisecond

I need to be able to measure time to a higher precision than Java provides. Is there any way that I can achieve this using a windows platform preferably?

Here is the code JNI C code:
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;
}Here is the java code:
import javax.swing.JOptionPane;
import javax.swing.*;
import java.net.*;
import java.awt.*;
public class Win32Native {
   public native double queryPerformanceFrequency();
   public native double queryPerformanceCounter();
   static {
         System.out.println("Loading library...");
         System.loadLibrary("Win32Native");
         System.out.println("Loaded ok!");
   public static void main(String[] args)  {
      Win32Native nat = new Win32Native();
      // You can call functions here as a quick test
      System.exit(0);
}

Similar Messages

  • Measuring time in milliseconds

    Hi,
    I have to measure time in millisecond between two user events in Applet, so I did this:
    Date startDate = new Date();
    // Users answer some questions
    Date endDate = new Date();
    int timeElapsed = endDate.getTime() - startDate.getTime();It was all fine, until the users figured out to cheat this system: they changed their computer's clock before answering the final question.
    So, is there any way to measure time in milliseconds and its independent from the computers clock?
    Thanks!

    meikop wrote:
    Thanks!
    I have a client - server application indeed.
    So as I understand, there's no good solution on the client (applet) side only - there's no way I can measure exact time and not be worried about clients computer clock? Any theoretical explenation ?
    Otherwise I have to mesure the time on the server side - I had it implemented some time ago:), but the clients started to complain about network latency etc so I decided to measure the time on the client side - not so good idea after all :)?
    I'll probably have to calculate each clients average network latency and so on...
    One can handle the client side clock being changed by the user by keeping a 'correction' in the client which is the difference between the client clock and the server clock. This way one only needs to update the correction at intervals - I use 1 minute update in my Bridge game. I don't need millisecond accuracy but it would not seem to be too difficult to correct for the network latency in calculating the correction.
    P.S. You would do better to use System.currentTimeMillis() rather than construct a Date() object which actually uses currentTimeMillis() behind the scenes.

  • Measure time of an measurement and if measurement time is less than 90 second wait until 90 second and then proceed to next steps or stop.

    Hi
    I am trying to make a program
          During execute a measurement count the time.
          If  measurement time is more than 90 second proceed to the next steps (or stop the measurement)
          If measurement time is less than 90 second, wait until 90 second and then proceed to next steps or stop
    I appreciate deeply if some help me.

    What sort of measurement are you talking about? What affects the time of your measurement? The very basic description you have is of a state machine and there are numerous examples of that
    1. Actually I would like measure the time of "Alignment" function done by wafer test equipment name Prober ( the model is "UF3000" made by TOKYO SEIMITSU CO., LTD.
    2.. Right now  the "Alignment" function is started when a  GPIB command is written as "N" and wait for resposne 70 in polling.
    Please refer to the attachment for Alignement function if it help you.
    In the attahement
    For Alignment error delay we are using =600
    Alignment counter =30000
    align loop cnt = 30000
    This is a program wriiten by another person and he is not availabe any more. What I am trying to do is
    1.  During execute a "Alignment " function count the time.
    2. If  "Alignment " function time is more than 90 second proceed to the next steps
    3.  If "Alignment " function is less than 90 second, wait until 90 second and then proceed to next steps
    Attachments:
    Alignment function.xlsx ‏153 KB

  • Measuring time between activation of two boolean

    Hello 
    I want to measure the time elapsed between activation of two boolean variables/indicators. In my code I have DAQ acquiring 2 digital signals which trigger corresponding 2 boolean indicators. Now I am trying to measure time between the event when my first boolean indicator gets the signal  and the event when my second boolean gets the signal. I am attaching my code. I checked DAQ and my indicators everything works fine, but just when I try running the code with the 'elapsed time' part, its not running. Any help will be appreciated.
    Thank You. 
    Attachments:
    Test Code.vi ‏45 KB

    So, feel free to give more detail. I'll just give you a couple thoughts:
    1) The primary issue with your code is that it probably doesn't do what you think it does. How this VI will run is that it will get one data from the DAQmx routine, then pretty much stay in the inner while loop since the event structure has an indefinite timeout. Worse, I don't think changing the value of the boolean controls would trigger the value changed event anyways. In the end, you don't even need the Event Structure to do what you want to do, nor do you need the inner while loop. Just check the values for each iteration of the outer while loop instead and do what you need to do with those.
    2) You are acquiring only one data point at a time. Which is OK if your events are particularly slow with respect to the effective sampling rate of the of loop (which might be able to pick up signals that change on the order of milliseconds or perhaps a bit less). If your signals are faster, you need to think about reading lots of samples at a time (arrays of booleans) and properly triggering your acquisition close to the event it needs to pick.
    3) If your signal is a pulse, make sure that the pulse width of the signal is much longer than than 1 / sampling rate. If it isn't, you could miss the pulse entirely doing this approach.
    4) The faster signals (as long as your have a quick enough sampling rate), the best thing is always to use a counters approach. In many of the DAQ cards and peripherals that NI offers, there are counters that can be driven with the sample clock (one of the fastest clocks on the device) or even a faster time base, and then the 'events' can be used to trigger acquisitions of the counters. Meaning you get exactly what you want: data points that correspond to times when events occur.

  • To high measurement time for NI PXI 4132

    Hi,
    I'm using 4132 to measure very small current of photo transistor device. with 25v source to the DUT it takes me more than 100ms to get an stable current reading.
    How will i reduce measurement time?
    tnx!

    Hi edakoto, 
    What current levels are you reading?  How are you acquiring the data in software?
    One thing to try is to reduce the Aperture time of the device.  The PXI 4132 defaults to an aperture time of 16.6 ms.  You can reduce this using the Configure Aperture Time VI or function.  For more information see here:
    http://zone.ni.com/reference/en-XX/help/370736F-01/ni_dc_power_supplies_help/4132_aperture/
    Thanks
    Patrick W.
    Applications Engineer
    National Instruments

  • I cut and pasted a description from the Internet. It posted as a link in iPhoto. It seems to have made a global change--all my descriptions are now blue, underlined, and Times Roman 12 rather than Arial white. How can I get this back to the default?

    I cut and pasted a description from the Internet. It posted as a link in iPhoto. It seems to have made a global change--all my descriptions are now blue, underlined, and Times Roman 12 rather than Arial white. How can I get this back to the default?

    Greetings,
    I've never seen this issue, and I handle many iPads, of all versions. WiFi issues are generally local to the WiFi router - they are not all of the same quality, range, immunity to interference, etc. You have distance, building construction, and the biggie - interference.
    At home, I use Apple routers, and have no issues with any of my WiFi enabled devices, computers, mobile devices, etc - even the lowly PeeCees. I have locations where I have Juniper Networks, as well as Aruba, and a few Netgears - all of them work as they should.
    The cheaper routers, Linksys, D-Link, Seimens home units, and many other no name devices have caused issues of various kinds, and even connectivity.
    I have no idea what Starbucks uses, but I always have a good connection, and I go there nearly every morning and get some work done, as well as play.
    You could try changing channels, 2.4 to 5 Gigs, changing locations of the router. I have had to do all of these at one time or another over the many years that I have been a Network Engineer.
    Good Luck - Cheers,
    M.

  • Jme - measuring time in nanoseconds

    Hi all!
    I'm developing an application for estimating cpu consumption on mobile devices.
    Actually I'm using the method currentTimeMillis() to take the time of a particularly bytecode instruction executed,
    but this is not enough for me. I need a more accurate method that can give me the time in nanoseconds,
    like nanoTime() available in jse (since 1.5).
    Anybody knows how can I solve this problem? Are there additional library or something like this?
    Thanks in advance,
    Fabiano.

    Nothing better than milliseconds is available. Maybe if you sign the app, and use JNI or something like that, but it wouldn't be portable(possible?) at all.

  • How can I measure time between transitions at digital input

    I am using LabVIEW 6.0 to measure the time duration between 2 transitions in a digital input port. I have a set up including an HP 34970A Data Acquisition unit with the 34907A Multifunction Module plug-in. The LabVIEW program is trying to poll the digital input for level changes and then using the Time function(Tick Count) to check the times at the transitions. However this method doesn't work reliably as I have to measure time periods of 500ms.
    Is there any good way of mesuring time period with the above setup. I don't have a module which connects to the internal multimeter in the 34970A. The other stuff I have are a HP 34903A(Actuator Module) and a HP 33120A(Function/Waveform Generator).
    Any method for m
    ore accurate time measurement with the above setup will be appreciated. If not, what else do I need to make accurate time measurements.

    Frankly I doubt that you're going to be able to measure time interval with much accuracy. You're periidically polling a static digital input and how often you poll is going to vary. You could try polling as fast as possible and eliminate as many background tasks as you can. If your tolerance for the measurement is plus or minus 100 msce, then maybe you'll get a decent measurement most of the time. If it's plus or minus 5/10 msec, then it will never happen. The pc's clock is just not that accurate and a software timed loop on Windows is not deterministic enough. Get a counter/timer board for something really accurate or use a scope to capture the waveform.

  • HT4623 I have updated my Iphone 3 but unable to start it. It takes too much time on Authentication and than message appears that Authentication failed

    I have updated my Iphone 3 but unable to start it. It takes too much time on Authentication and than message appears that Authentication failed

    I don't know either its jailbroken or hacked otherwise.
    It was working properly before I have updated it through Itunes to update the OS. After the updation, this message occurs
    Authentication failed, please try after few minutes
    Please help

  • How can I get the Elapsed Time express to output in milliseconds?

    I am trying to get the Elapsed Time express to output in milliseconds or in seconds to three decimal places. I am pretty new at this.
    Thanks in advance!

    I'm not sure I understand your question. The output of the Elapsed Time Express VI is a DBL. It's already a floating point number. The default format for a numeric indicator is 6 digits of precision. You can change this in the properties for the indicator.
    To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
    Attachments:
    Example_VI.png ‏4 KB

  • Is it possible to stretch or make the time line smaller or consolidate it?

    Hi how do I consolidate adobe flash arrange window area so that I can make my time line small to be able to see the whole movie with keyframes how I want to see them.  there are some times I have to scrool alway the way right, how do i avoide from doing this?
    Something similar to how adobes audition stretches waves is this possible to do in your timeline?

    You're basically just changing the size of the frames in the timele. Selecting the smallest possible size frame will of course allow more of the timeline to ve seen in the viewable area. I understand that sometimes no matter what you do, you may end up with timelines containing a lot of frames. But this can be minimized by making good use of embedded movie clips and AS classes for teed ing and other things that normally require frames and keyframes.

  • Ni scope measurement time delay

    使用niscope measurement  测量 time delay ,如何使测量更加准确,现在测出来的值的浮动范围很大,另,能不能提供其测量的具体算法编程

    The PXI 1031 is just the chassis and power supply.  It does not read anything.  So I am guessing that the 5105 is doing the measurements.
    What is the resistor value you are using to convert the current to voltage?  Have you verified that the resistor is actually close to the nominal value? Is the voltage in the current loop within the common mode range of the measurement device?  Do you have the loop grounded at two different points?  Does the pressure actually exceed 62 bar?  Does the current from the transducer actually go to 20 mA?
    Your calculation is correct for a 1-5 V input corresponding to 0-100 bar.
    You have several questions which all seem to be related to the same project.  Do you have a good overall plan for the total project? Did someone sit down and create a specification for the hardware and the software? Have the various subsystems been designed in detail before you started developing code and buying hardware?  Do you have a System Architect (Project Manager, or other title) who has a good overall idea of how this thing is supposed to work?
    Without that you will likely continue to be frustrated and not too productive.
    Lynn

  • Best way to measure time?

    I have labview 7.0 and SC-2345 with several digital inputs. I have to measure time between digital input(rise or fall)and stop signal comes in my program with compare etc.
    I have tried to measure time with 4 sequences and "get date/time in seconds" and i have also tried to use loop with shift register.
    It seems not to work or accuracy is not enough. so how to do that?

    I am very sorry If you feel I came across unfriendly in any way, my intentions were sincere and I wanted to help you improve your code by pointing out some common mistakes. Believe me, some of my early labVIEW diagrams from 10 years ago are much worse. In the meantime I have accumulated some experience with daily use, but am still learning every day.
    By the way, I an not affiliated with National instruments. This is mostly a peer help forum where LabVIEW users from all over the world help each other improve their coding skills. (Only users with blue names are employed by NI!)
    Certain things are not obvious looking at your code and once the desired functionality is clear we can help you to a more optimized version that actually works. Whatever you are feeding to the "elapsed time" indicator has nothing to do with elapsed time, but counts the iterations of the middle while loop. It is either 1 or 2, depending on the inputs. There has to be a more interesting output (see my next post!).
    For example, let's just look at your inner while loop (see attached image). (1) The number of iterations is known when the loop starts, thus a FOR loop is more appropriate. (2) You are comparing a DBL with an integer using "equal". If by chance the operator would enter a fractional time (e.g. 1000.5), the comparison would never become true and this loop would go on forever. Your program will never finish! Not good!
    An alternative, but safe code is shown below in the image. For integer times, it has exactly the same functionality.
    Apparently, you want to measure elapsed time, and I am guessing elapsed time used by the code in your middle loop. I will attach a simplified example based on your program in the next message here.
    LabVIEW Champion . Do more with less code and in less time .

  • "Measurement time cannot be in the future ".

    Hi Gurus
    I am doing testing for a Computer manufacturing company.When i am trying do confirmation against a production oder via t code CO11N system giving the message "Measurement time cannot be in the future ".
    Could you pls help to resolve this issue.
    Regards
    Sandip

    Hi
    Posting date is the current date.The details of the error given below.
    Measurement time cannot be in the future
    Message no. IR023
    Diagnosis
    The measurement time that you have entered is in the future.
    A measurement reading describes an actual state, and therefore the measurement time cannot normally be in the future.
    System Response
    Processing will not be continued.
    Procedure
    Enter a measurement time in the past.
    If this is an exceptional case, contact your system administrator.
    Procedure for the system administrator
    In exceptional cases, tolerances must be allowed in the entry of measurement times.
    Example:
    Measurements are taken automatically and are then transferred to the SAP System. The system time of the measurement system varies from that of the SAP System for technical reasons.
    You can define an appropriate tolerance level in Customizing for each measuring point category.
    Pls suggest some solution.
    Regards
    sandip

  • ME51n, ME21n Unit of measure F4 shows all units

    Dear Gurus,
    Transaction ME51n & Me21n
    PR & PO line item Unit of Measure F4 show only commercial unit list. This is Ok.
    But when we create Service PR or Service PO, the Item service details Unit of Measure F4 shows all Unit of measures (all entries in table T006) (commercial unit + other non commercial units).
    Kindly inform why the Service detail Unit of Measure F4 show all the list.
    Is it correct system behavior?
    Thanks and Best Regards,
    Mohan

    i believe there is nothing worng with the system
    as both are different table and moreover the data element for the field MIENS in both the tables is different
    and i believe that reasons behind this is in case of service unit of measure can be a non dimenetional one as it is a functional requirement or a businees requirement
    but in case if you order a material then in that case you need a specific and comercial unit of measurement
    so as per my undersatanding nothing wrong in the system

Maybe you are looking for

  • Can no longer playing my own podcasts with QuickTime on Mac.

    When checking my latest Garage Band podcast, I got ? in Q with message to download latest QuickTime. I did that but still get ? in Q. I can play my podcasts on PC with QuickTime in Windows XP, but not on my Mac. My 2GHz Macbook is new and has no addi

  • How do I change the font size in iPod touch with iOS 6.1.3?Thanks

    How do I change the font size in iPod touch with iOS 6.1.3?Thanks

  • Can I execute C code in current Thread(process)?

    Hi all, I want to execute a Linux command within current Thread, but Runtime.exec() will start a new process to execute the command specified. Does JNI can execute any system command or any C program in current Thread? BTW, I tried JNA, following cod

  • Quicktime: "Required Compressor Could Not Be Found"

    OK, I have a Powerbook G4, running Mac OS X 10.2.8 (1.33 GHz PowerPC) I'm running Quicktime version 6.5.2. I've just downloaded some quicktime videos I just need to watch on my computer, Quicktime is opening the files with the notice: You may experie

  • Can I safely uninstall 1.5 now?

    I bought the v2.0 upgrade at the same time as a new PC. Unlike both Premiere and Audition, Encore would not insatall from just the ugrade disk (Premiere and Audition simply asked for earlier version serial numbers as proof of ownership) but instead I