none
I have a application take 2 minutes during run it for the first open while it takes 10 seconds for run after open existing file (second run). How I can reduce the time of first run? RRS feed

  • Question

  • Hi,

    I have a application take 2 minutes during run it for the first open while it takes 10 seconds for run after open existing file (second run).  How I can reduce the time of first run?

    Knowing that all variables are defined as friend in the module.

    Kind Regards,

     


    Hany Metry

    Sunday, March 1, 2020 11:53 AM

All replies

  • Hello,

    It's impossible to provide a recommendation without know the code which takes two minutes to load then ten seconds to load.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, March 1, 2020 11:56 AM
    Moderator
  • Hello,

    It's impossible to provide a recommendation without know the code which takes two minutes to load then ten seconds to load.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Hi,

    The load take 5 seconds while only first run (execute), the of the application takes 2 to 1.0 minutes (the application provide the first output of the problem) and then open existing file the results of open existing file takes 10 seconds or less.<o:p></o:p>

    Kind Regards,<o:p></o:p>



    Hany Metry

    Sunday, March 1, 2020 12:06 PM
  • Still do not see your code so still can't help you.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, March 1, 2020 1:23 PM
    Moderator
  • Still do not see your code so still can't help you.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Hi,

    The code is about 300'000 Lines, cant written.

    Same code is used for second run, then the problem is not due the code while I think, there is other problem.

    Kind Regards,


    Hany Metry



    • Edited by Hany Metry Sunday, March 1, 2020 2:13 PM Same code is used for second run, then the problem is not due the code while I think, there is other problem
    Sunday, March 1, 2020 1:54 PM
  • Hi,

    If you open existing file after load the application, the out put takes 1-2 minutes while open second existing file, the output takes 10 seconds.

    How to reduce the output time for opening first existing file.

     


    Hany Metry

    Sunday, March 1, 2020 2:25 PM
  • Still do not see your code so still can't help you.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Hi,

    The code is about 300'000 Lines, cant written.

    Same code is used for second run, then the problem is not due the code while I think, there is other problem.

    Kind Regards,


    Hany Metry



    I suggest using the debugger in tangent with the performance profilter then to figure out the problem. Otherwise nothing I can. Lastly, can't imagine that all 300,00 lines of code run during the time of the problem.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, March 1, 2020 3:03 PM
    Moderator
  • Dear Sir,

     If Execute.Checked = True Or ExecuteToolStripMenuItem.Checked = True Then
                intitalizasecond()
            End If

     without debug, maybe the above code, make the problem.

    Actually it is much than 300'000 lines codes but 300'000 line code does not used at each run while there are many if statement which make the maximum run lines = 60'000 Lines 

    The above code is initialized the second run and it makes many array = 0.0 but still that code used for both open first existing file and second existing file.

    Kind Regards,


    Hany Metry

    Sunday, March 1, 2020 3:33 PM
  • Hi

    This is something I have noticed before.

    Always when the code does a fair bit of disc access (such as listing files etc) immediately on starting.

    I think it may be something to do with system caching file info where first run it has no chache but subsequent runs it does have info on hand.

    *

    Does your code do some file accessing on startup?


    Regards Les, Livingston, Scotland


    • Edited by leshay Sunday, March 1, 2020 4:08 PM
    Sunday, March 1, 2020 4:07 PM

  • I have a application take 2 minutes during run it for the first open while it takes 10 seconds for run after open existing file (second run).  How I can reduce the time of first run?


    As Les suggested, if you are complaining about the time it takes to read/write a
    disk file the first time compared to how long it takes if you read the same
    file again soon after the first, then caching is the most likely reason.
    In such cases it isn't that the first time the file is read is too slow -
    it is operating at the speed of the disk. The second time the same file
    is read (soon after the first time) it is retrieved from the cache in memory
    so is much quicker.

    If you have a system with a fair amount of memory try doing a search of your
    entire hard drive for files with some arbitrary (perhaps non-existent) file
    extension. You should see and hear a significant amount of disk activity
    the first time. As soon as it finishes run it again. You will probably see
    little or no disk activity and the search will be much faster than the first 
    time.

    This is not a programming issue, it is normal operating system behaviour.

    Another OS factor that can impact performance is "Indexing". If the system
    is configured to index files (especially if it includes file contents) then
    access times can be slow before or while the index is created/updated. But
    it may be much faster afterwards.

    If you can test the timing of your program when the file is on a solid state
    drive you may get a better sense of performance when physical factors are
    eliminated or reduced.

    - Wayne

    Sunday, March 1, 2020 7:53 PM

  • I have a application take 2 minutes during run it for the first open while it takes 10 seconds for run after open existing file (second run).  How I can reduce the time of first run?


    As Les suggested, if you are complaining about the time it takes to read/write a
    disk file the first time compared to how long it takes if you read the same
    file again soon after the first, then caching is the most likely reason.
    In such cases it isn't that the first time the file is read is too slow -
    it is operating at the speed of the disk. The second time the same file
    is read (soon after the first time) it is retrieved from the cache in memory
    so is much quicker.

    If you have a system with a fair amount of memory try doing a search of your
    entire hard drive for files with some arbitrary (perhaps non-existent) file
    extension. You should see and hear a significant amount of disk activity
    the first time. As soon as it finishes run it again. You will probably see
    little or no disk activity and the search will be much faster than the first 
    time.

    This is not a programming issue, it is normal operating system behaviour.

    Another OS factor that can impact performance is "Indexing". If the system
    is configured to index files (especially if it includes file contents) then
    access times can be slow before or while the index is created/updated. But
    it may be much faster afterwards.

    If you can test the timing of your program when the file is on a solid state
    drive you may get a better sense of performance when physical factors are
    eliminated or reduced.

    - Wayne

    Hi Sir,

    I am not understand clear your reply because I am weak at that point while my feel that your reply is correct (the problem related with the cash), but I want to highlight that the much time spent is not for reading the file while for mathematical calculations of output while if I reopened same file again or even new file, the mathematical calculations of output take very short time.

    I have not output files while the output are shown in the screen.

    Most of 350'000 lines are mathematical calculations with very big numbers of if statements, so the program only use 1% to 2% of the lines for calculations.

    What you mean by file on solid state drive?

    My computer is 4 GB ram, 64 bit and i3, if the rams become 16 GB or if the computer is i7 that will enhance the time of first run the outputs?

    Kind Regards,


      

       


    Hany Metry



    • Edited by Hany Metry Monday, March 2, 2020 12:28 AM
    Monday, March 2, 2020 12:14 AM
  • Hi

    Generally speaking, the time used for calculations, assuming they are the same calculations each time shouldn't be so much different to be noticable.

    Does your code do any file access/reading/writing/collecting/copying at all during the time where the 'long time' is noticed?

    Can your issue be resolvd if the code involved is done on a seperate thread thus making the User UI interaction active and smooth?


    Regards Les, Livingston, Scotland

    Monday, March 2, 2020 12:29 AM
  • Hi Hany,

    How have you been?  :)

    It is impossible to guess what you did not do correctly. Like proving the negative.

    "350'000 lines are mathematical calculations with very big numbers of if statements,"

    No offense but how can you possibly think that is a practical solution?

    The odds are 99 to 100 the problem is bad programming logic and nothing else.

    Yours will be the only 350000 if statement math equation on the planet.

    Congrats. Must be a record.

    Sorry but someone needs to say it.

    I just am being Nean.

    :)

    Monday, March 2, 2020 12:47 AM
  • Hi

    Generally speaking, the time used for calculations, assuming they are the same calculations each time shouldn't be so much different to be noticable.

    Does your code do any file access/reading/writing/collecting/copying at all during the time where the 'long time' is noticed?

    Can your issue be resolvd if the code involved is done on a seperate thread thus making the User UI interaction active and smooth?


    Regards Les, Livingston, Scotland

    Hi,

    The code does not do any file access/reading/writing/collecting/coping at all during the time where the 'long time' is noticed.

    The calculation may be not the same calculation or maybe same calculation, if i open same file.

    Regards,


    Hany Metry

    Monday, March 2, 2020 12:51 AM
  • Hi

    OK, the file you open varies and the calculations vary too.

    Is the 'long time' startup related to the size of the file and/or the amount of calculations done?


    Regards Les, Livingston, Scotland

    Monday, March 2, 2020 12:54 AM

  • The code does not do any file access/reading/writing/collecting/coping at all during the time where the 'long time' is noticed.

    The calculation may be not the same calculation or maybe same calculation, if i open same file.


    It should be obvious that if the calculations are different there may be
    differences in the time it takes to complete the calculations.

    Run a Profiler multiple times and watch where the code is spending most of its
    time. You can start with the Profiler included in Visual Studio.

    - Wayne

    Monday, March 2, 2020 1:10 AM