Calculate the time spent to execute your program

Hi
I have a pgm which calculates the response time in milllisecond using method System.currentTimeMillis(). And I get answer 0.
My question is If we measure the time in terms of nanosecond, do you think we still get zero answer?and What is your explanation for that?
Waiting for reply. Thanks in Advance
Regards,
Jyoti

Hi,
Here is the code for calculating the response time.
public class RunLinkedEvenOddList {
     public static void main(String[] args) {
          long time1;
          long time2;
          time1 = System.currentTimeMillis();
          System.out.println("Program 2 output:");
LinkedEvenOddList eolist = new
ew LinkedEvenOddList();
          eolist.insert(9);
          eolist.insert(4);
          eolist.insert(3);
          eolist.insert(2);
          eolist.insert(5);
          eolist.print();
          System.out.println("print Even:");
          eolist.printEven();
          System.out.println("print Odd:");
          eolist.printOdd();
          eolist.delete(9);
          eolist.delete(1);
          System.out.println("list after delete 9, 1:");     
          eolist.print();
          System.out.print("execute isMemeber(3): ");
          System.out.println(eolist.isMember(3));
          time2 = System.currentTimeMillis();
System.out.println("The starting time: " + time1 +
+
                    " milli seconds.");
          System.out.println("The ending time: " + time2 +
                    " milli seconds.");
Answer the following questions based on the output of
your code:
1. Calculate the time spent to execute your program
based on the value of time1 and time2; you need write
your formula first and then give the answer in
millisecond.
Answer:
time2-time1
time spent to execute your program = 0 millisec
2. If we measure the time in terms of nanosecond, do
you think we still get zero answer?
Answer:
3.What is your explanation for that?
Answer:
Pls help me in answering question 2 and 3. Thanks in
advance.Hai Ram!
Yeh homework mai hai.
Akhela mai karo. (Do your own work).

Similar Messages

  • Need  the query to calculate the time taken to excute it.

    hi all,
    i need the query to calculate the time taken to excute it.
    for ex:
    select * from emp;
    how much time it will take to give o/p
    Thanks in advance
    satya

    Just to add to what was said - the execution can each time be DIFFERENT as the factors that governs performance are NOT CONSTANT.
    If Oracle has no idea how long the query is going to take before executing it, then how can you and your code know?
    Oracle's CBO estimates the cost (expense) of the query. This is an indication of how expensive a query is - and the more expensive the query, the more resources need to be used, the longer the query will take. The less expensive the query, the fewer resources it need, the faster it will take.
    And that is it. How fast or how slow? Oracle does not know. How much faster a query with a cost of 10,000 versus a query with a cost of 1? Oracle does not know.
    Why? Because the platform is not constant. Just what data is at this exact moment in the db buffer cache? Just how much CPU capacity is available for the new few seconds? Just what will the sustained throughput be of the I/O subsystem and channels for the next minute? Just how many memory pages need to be swapped between cache and memory? Etc. etc.
    All these factors change every single second. So forget about attempting to accurately calculate up-front the time it will take for a query. IT IS NOT POSSIBLE.

  • How to calculate the number of days until your next birthday. Only using current month, day and birth month and day.

    I'm trying to calculate the number of days until your next birthday. Only using current month, day and birth month and day. I can get close but i'm way off. When i enter in the next day, the amount of days is supposed to be 364. This is where I am having problems. I know my code is way off. I just need some guidance please!
    Attachments:
    D5.7_1.vi ‏8 KB

    I just had a little fun with the Time Record...
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    D5.7_1_BD.png ‏19 KB

  • How to calculate the time between start trigger,first scan and first A/D in DAQ

    Environment: Labview 6.1, N6052E DAQ board(max scan rate=333KHz, max channel rate=333KHz, settling time=3.5usec+1LSB)
    I am using external scan clock 10K scan/s collecting data on 16 AI channels, and external channel clock 200KHz.
    Could show me how to calculate the time betweent he start trigger, the first scan and the first A/D conversion?
    Thanks

    I read the one you give to me. still cannot work out. I am using Labview 6.1 DAQ vi, including AI config.vi. clock config.vi, AI control.vi, AI read.vi, working on colect data on 16 AI channels. So I belong to SCAN function and external scan and sampling timing, right?
    But it says the T1 and T2 are determined by external signals. How can I calculate that?
    T1=1/10KHz or T1=1/160Khz?
    T2=1/200KHz?
    Is the above correct?

  • Calculate the time remaining during File Download ?

    Hi
    I need to calculate the time remaining of file download . I am using NSURLConnection for file download in Cocoa . I am able to show the download progressbar . I want to show the time remaining for complete download and it should vary if network signal fluctuate .
    Please guide me ...
    Thanks

    The tricky part is to define what is a disturbance
    First do once  a correlation to find and correct a shift in the signal
    Look at the (absolute or squared) difference of both signals and define a threswhold and use the threshold detector vi
    from the point location(s) calculate the time and log it.
    And have a look at the waveform monitoring vis....
    Greetings from Germany
    Henrik
    LV since v3.1
    “ground” is a convenient fantasy
    '˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'

  • How to Calculate the Time Between two days in ABAP

    Hi,
                  I have one scenario like i need to calculate the time between two days please can you suggest me.
    Thanks,
    Harinath

    Hi Peeleti,
                Check this code,
    DATA : DATE1 LIKE SY-DATUM VALUE '19830125',
           DATE2 LIKE SY-DATUM VALUE '20070219',
           DAYS1 TYPE I,
           WEEK1 TYPE I,
           MONTH1 TYPE I,
           YEAR1 TYPE I,
           C_YEARS1 TYPE I.
    CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
    EXPORTING
      BEGDA           = DATE1
       endda           = DATE2
      TAB_MODE        = ' '
    IMPORTING
      DAYS            = DAYS1
      C_WEEKS         =
      C_MONTHS        = C_YEARS1
      C_YEARS         = C_YEARS1
      WEEKS           = WEEK1
      MONTHS          = MONTH1
      YEARS           = YEAR1.
      D_MONTHS        =
      MONTH_TAB       =
    *WRITE : / 'DAYS   = ', DAYS1,
            / 'WEEKS = ',WEEK1,
          /  'MONTHS = ', MONTH1,
          / 'YEARS   = ', YEAR1.
    Using this code you can calculate the No Of Days Between two dates. Based On days you will easily calculate the Hour. [  No of days * 24 ].
    Thanks.
    Reward If helpful.

  • How to calculate the time difference in answers

    Hi,
    I need to calculate the time difference in BI answers and I dont have the access to the repository. I have the data in the following format
    10/12/2005 7:24:19 PM 10/12/2005 7:32:04 PM
    10/12/2005 7:50:47 PM 10/12/2005 8:52:36 PM
    10/12/2005 7:54:23 PM 11/4/2005 10:47:32 PM
    10/12/2005 9:05:51 PM 10/12/2005 9:08:58 PM
    10/12/2005 9:07:42 PM 10/12/2005 9:14:47 PM
    10/12/2005 9:09:02 PM 10/12/2005 9:10:57 PM
    I need to get the elapased hours between these two columns. Please help me
    Thanks

    you can use beans or create a case when statement like:
    case
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 60 then 1 else
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) > 60 and TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 90 then 1.5 else
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) > 90 and TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 150 then 2.5 else
    end

  • How to calculate the time to render a JTable?

    Hi all,
    I have a table that is taking quite some time to render after I edit one of its cells.
    I'd like to know the complete amount of time it takes to render all the cells.
    Considering the cells are rendered inside the java classes, I have no clue how can I do that.
    Any help would be appreciated.

    878279 wrote:
    Tried VisualVM and it's really a nice tool. The problem is that it shows only the time for each method to run.Exactly, so if you look at the event queue thread and drill down you can see which method is 'taking quite some time' after you did an edit. Note that you typically need to drill down a bit into the Swing painting stack but ultimate it's end up in the methods you wrote.
    See for example: http://imageshack.us/photo/my-images/827/simplecpusampling.png/ when sampling this program:
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    public class TestCPUSampling {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    DefaultTableModel slowModel = new DefaultTableModel(5, 5) {
                        @Override
                        public Object getValueAt(int row, int column) {
                            try {
                                Thread.sleep(10);
                            catch (InterruptedException e) {
                                e.printStackTrace();
                            return super.getValueAt(row, column);
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.getContentPane().add(new JTable(slowModel));
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
    }Obviously Oracle should do something about that horribly slow Thread#sleep() method...
    But if your getValueAt() is called 15 million times, then it's more likely you have a loop like a TableModelListener which modifies the table model when the table model changes.

  • How to calculate the time duration on a datetime column?

    Hi guys,
    I've done some search on this forum and everywhere else but I can't seem to get this right, at the beggining it sounded like something very simple to accomplish, for the instance with Excel but I'm struggling to get it to work with Crystal Reports on Microsoft Visual Studio 2008.
    I have a datetime column (SQL Server 2000) that I wanted to calculate the the time duration on the report group footer, unfortunatelly the built-in SUM function cannot be applied and I've tried several formulas that I've found on the internet without any luck. I'm using a datetime column to store only the time because I'm stuck with SQL Server 2000 which doesn't have a time data type.
    Would you guys know how to do it by any chance?
    Some sample code I've tried: http://www.minisolve.com/TipsAddUpTime.htm
    Thanks a lot,
    Paul
    Edited by: Paul Doe on Dec 12, 2009 5:41 PM
    Some sample data:
    EMPLOYEE     WORK HOURS
    =========     =================
    JOHN DOE      1900-01-01 01:00:05
    JOHN DOE      1900-01-01 00:20:00
    JOHN DOE      1900-01-01 01:30:15
    =========     =================
    HOURS WORKED: 02:50:20
    Edited by: Paul Doe on Dec 12, 2009 5:42 PM
    Edited by: Paul Doe on Dec 12, 2009 5:45 PM

    Guess what, by further testing the code on the website mentioned above I got it working.
    Pus, I needed to change the grouping on the code, so I had to come up with a way to update the formulas based on the groupping field.
    Considering "call_date" is the field that you are groupping by on the designer use the following code to update the formula:
    CrystalReportObj = new ReportDocument();
    CrystalReportObj.Load("C:\\reportfile.rpt");
    FieldDefinition FieldDef;
    //Get formula
    FormulaFieldDefinition FormulaDef1;
    FormulaDef1 = CrystalReportObj.DataDefinition.FormulaFields["SubHours"];
    //Get formula
    FormulaFieldDefinition FormulaDef2;
    FormulaDef2 = CrystalReportObj.DataDefinition.FormulaFields["subMinSec"];
    //Update the formula to work with the new grouping field,
    //this must be called first else will throw an exception
    FormulaDef1.Text = FormulaDef1.Text.Replace("call_date", "call_extension");
    FormulaDef2.Text = FormulaDef2.Text.Replace("call_date", "call_extension");
    //Get the new field we are grouping by
    FieldDef = CrystalReportObj.Database.Tables[0].Fields["call_extension"];
    //Replace current grouping field with the new one,
    //considering there only one group in the report, index 0
    CrystalReportObj.DataDefinition.Groups[0].ConditionField = FieldDef;
    Have fun.
    Edited by: Paul Doe on Dec 12, 2009 8:43 PM
    Edited by: Paul Doe on Dec 12, 2009 8:53 PM

  • Identifying the time spent on each step in Proxy Service?

    Hi Everyone,
    Is there anyway to identify how much time each step in proxy service is taking?
    I am using OSB 10.3.1
    Thanks & Regards
    Himanshu

    Yes there is.
    Open sbconsole.
    Go to operations tab on your proxy service, select Monitoring, enable it by selecting the checkbox.
    Then, in the section on alerts, you would see a drop down having three values - Service Level, Pipeline Level, Action Level (or maybe activity level, have forgotten). Select the Action Level.
    Run your proxy service for the desired time.
    In the sbconsole dashboard, you should be able to see the Metrics of each action within the proxy service. It is most probably found in the last tab of monitoring page within OSB Dashboard.
    Hope this helps.

  • How to calculate the Time difference between 2 dates

    HI All,
    I am using HR_hk_diff_btw_2_dates to calculate the employee service dates.
    For that i  am inputing his hire date and Term dates and Output format as '05' i am getting output perfectly....
    But problem is  whe i am inputting the employee hire date is Dec 1 2007 and Term date is
    March 31 2009 It is coming as 1 year 3 months  31 days instead of 1 year 4 months directly .......How could we make it make last date also working day and get the O/p as 1 year 4 months ?Please Advice..
    Regard
    sas

    1. FM for difference betwwen two times:SCOV_TIME_DIFF
    Import parameters               Value
    IM_DATE1                        2008-01-01
    IM_DATE2                        2008-01-01
    IM_TIME1                        10:00:00
    IM_TIME2                        11:30:00
    Export parameters               Value
    EX_DAYS                         0
    EX_TIME                         01:30:00
    2. SD_CALC_DURATION_FROM_DATETIME : Finds the difference between two date/time and report the difference in hours
    L_MC_TIME_DIFFERENCE : Finds the time difference between two date/time

  • How to calculate the time between triggering the signal and receiving back

    i want the time elapsed between triggering the signal and receiving it back through a ultrasonic sensor in compactrio labview fpga.

    thank you sir for your reply, but im working on fpga target cRIO-9082 chassis it wont support those palletes , yah if i dont work on fpga target then i can use those palletes ....in attaching the vi for generating a digital pulse and acquiring it back but yrt dint got any idea hot to determine the time...if the vi is wrong please make the neccessary changes. i used this vi to determine the total time between trigger and receving signal of ultrasonic sensor.
    Thank you 
    Attachments:
    pulse generation.vi ‏51 KB

  • Calculate the time different of the graph

    Hi,
    How can i get the time different of the section graph by pointing at it as show in attachment .jpg.
    Other than using the cursor, is there any other methods of doing it??
    Attach with my vi & data.
    thanks and regards,
    Simon
    Attachments:
    pattern.JPG ‏119 KB
    sleep analysis.vi ‏20 KB
    Output_Graph.vi ‏16 KB

    Here's the data..
    Attachments:
    sleep analysis.txt ‏1 KB

  • How to set the time limit to execute shell script

    I am using Runtime exec() method to execute a shell script
    if the script hangs for long time infinitely then how to get the control
    return to the program.
    Thanks in advance

    rmi_rajkumar wrote:
    let me explain with an example
    script name is test.sh
    Runtime.exec("test.sh") this will start a new process
    if (proc.waitFor() == 0) {
    try {
    InputStreamReader isr = new InputStreamReader(proc.getInputStream());
    BufferedReader br = new BufferedReader(isr);
    String line;
    while ((line = br.readLine()) != null) {
    outputBuf.append(line).append(ConfigOptions.getLineModeStr());
    } catch (IOException ioe) {
    if test.sh did not exit and hangs with no response
    in this case proc.waitFor() will not execute try catch the control will remain if statement
    my question is insteadof waiting indefinitely need to set a time out say 1 hour and kill the process that executed the scriptYou really need to read the article in the link given by another poster. Your code will not work correctly because you are waiting for the process to end before reading the stream and the processes may never end because you are not reading the stream until after it ends (you need to use muli-threading as explained in the article). If the process really did hange you could probably use destroy(); but, for now, the real problem is your code.

  • How can we recognize the time taking for executing any process chain

    Hi,
    I have one metachain which consists of several local process chain. It was executed successfully. So how can I find out total time for executing this meta chain.Is there any way to find out that this process execution time is lile some hours and some mins.

    ST13 trans description is Analysis & Service Tools Launch pad and is part of the ST-A/PI plugin.  See Note 69455 - Servicetools for Applications ST-A/PI (ST14, RTCCTOOL, ST12) aand talk to your Basis folks to find out if they can install it since it sounds like it is not installed at your site.
    Here's a list of functions the tool provides - only some are BW specific, so if you can not get ST13 authorization, see if you can at least run the pgm
    Analysis/Service Tools
    Name                     Title                                          
    RTCCTOOL              SAP Servicetools Update
    ST12                        Single transaction analysis
    SDCCVIEWER          SDCC: View data from ST-A/PI subroutines
    SOS_CUSTOMER_DATA                Customer Checks for Security Optimitation
    BATCH_JOB_ANALYSIS               Batch job analysis
    CMO_SYSTEM_MONITORING            CMO - System Monitoring
    ITSTRACEVIEW                     ITS trace viewer (SAPjulep) for EBP/CRM
    STAD_DATA_GET                    Select STAD data and put to download
    BPSTOOLS                         BW-BPS Performance Toolset
    BIIPTOOLS                        BI-IP Performance Toolset
    BW_QUERY_ACCESSES                BW: aggregate/InfoCube accesses of queries
    BW_QUERY_USAGE                   BW: query usage statistics
    BW-TOOLS                         BW Tools
    SEM_BCS_STATISTIC_ANALYSIS       SEM-BCS: Statistic Analysis
    BWQUAC_CUST                      BW Query Alert Collector Customizing
    TABLE_ANALYSIS                   Table Analysis Tools
    UPGRADE_TOOLS                    Tools for Upgrade
    MASS_MAN_MONITORING              Monitoring for Mass Data
    CUST_DMA_TAANA                   DVM: Settings for ST14 CA
    PROJBROWSER                      Service Software: Local project browser
    ANALYSISBROWSER                  Service Software: Analysis browser
    SDCC_DOWNLOAD_SIMULATION         SDCC download simulation for ST-A/PI collectors
    TEXTBROWSER                      Service Software: Short&Longtext browser
    SET_SDCC_PRODUCTIVE_CLIENT       Manually set analysis client for SDCC datacollection
    There were a few OSS Notes relating to ST03N dumping you might want to review to see if they need to be applied
    Nothing is ever as easy as it ought to be.

Maybe you are looking for

  • Error during creation of new movement types

    hi frnds,     while creating a new movement type for 311 with z11....in help text tab..it is showing an error.. " Entry HULIST does not exist in TSTC (check entry) "...how do i resolve this. Regards, Prasath

  • Non-static variable total cannot be referenced from a static context

    i am trying to write a program that uses the if-else statements and when i wrote my program i got "non-static variable total cannot be referenced from a static context" for three lines of my input. A:\Disks.java:20: non-static variable total cannot b

  • Difference in CIN configuration of depot sales and factory sales

    Hi all, I have just completed CIN configuration of a manufacturing plant. I want to know waht would be different in cin configuration of depot sales and factory sales. please guide me in this regard. thanks, Vikrant

  • BAPI_CTRACDOCUMENT_CREATE

    Hi, I am creating Doc 1 using this BAPI. Now , I am creating Doc 2 using the same BAPI with reverse values(+ to -). It is creating both the documents. Now, I want to clear Doc 1 with Doc 2 and I want to clear Doc 1 at the same time , when I am creati

  • Transaction CJI3 in portal Problem

    Dear Friends, We are working with CJI3 Transaction in Portal that is linked to a BW Report , the flow is BW report should flow to CJI3 by taking the Projects as Input and gives the Output along with Summarization of Cost Centers, The Problem now is w