Skip to main content
Fixed formatting and a bunch of clarity, grammar, and capitalization issues
Source Link

I have a function that runs for about 0.7 seconds on my not-so-new developdevelopment machine. (it runs for about 3 seconds on another machine I tested)

I want to show the user some pre-message about half a second before the above function is done.

I don't want to show the message too long before the function is done as it will be annoying to just look at it and wait...

  On the other hand, I would rather not wait until the function is done because the whole thing starts from a user action and I don't want to "waste"waste time - it's better if I can show that message while the other function is doing it'sits job.

I've already added a loop with a short Thread.sleep()Thread.sleep() to let the pre-message hang if the function was "too fast" but I'm afraid that usually wontwon't be the case...

  And so...., I want to see if I could roughly estimate the execution time basebased on current machine specifications and even by the current CPU usage. and do that before running the function.

  Also, since we are talking about seconds and milliseconds, if getting this information will take more thethan a few milliseconds then it's not worth it... inIn this case, I might calculate it only once when the application is loaded.

Anybody hasDoes anybody have an idea how to do that?

Thanks alot

I have a function that runs for about 0.7 seconds on my not-so-new develop machine. (it runs for about 3 seconds on another machine I tested)

I want to show the user some pre-message about half a second before the above function is done.

I don't want to show the message too long before the function is done as it will be annoying to just look at it and wait...

  On the other hand I rather not wait until the function is done because the whole thing starts from a user action and I don't want to "waste" time - it's better if I can show that message while the other function is doing it's job.

I've already added a loop with a short Thread.sleep() to let the pre-message hang if the function was "too fast" but I'm afraid that usually wont be the case...

  And so.... I want to see if I could roughly estimate the execution time base on current machine specifications and even by the current CPU usage. and do that before running the function.

  Also since we are talking about seconds and milliseconds, if getting this information will take more the a few milliseconds then it's not worth it... in this case I might calculate it only once when the application is loaded.

Anybody has an idea how to do that?

Thanks alot

I have a function that runs for about 0.7 seconds on my not-so-new development machine. (it runs for about 3 seconds on another machine I tested)

I want to show the user some pre-message about half a second before the above function is done.

I don't want to show the message too long before the function is done as it will be annoying to just look at it and wait. On the other hand, I would rather not wait until the function is done because the whole thing starts from a user action and I don't want to waste time - it's better if I can show that message while the other function is doing its job.

I've already added a loop with a short Thread.sleep() to let the pre-message hang if the function was "too fast" but I'm afraid that usually won't be the case... And so, I want to see if I could roughly estimate the execution time based on current machine specifications and even by the current CPU usage and do that before running the function. Also, since we are talking about seconds and milliseconds, if getting this information will take more than a few milliseconds then it's not worth it. In this case, I might calculate it only once when the application is loaded.

Does anybody have an idea how to do that?


i have a function that runs for about 0.7 seconds on my not-so-new develop machine. (it runs for about 3 seconds on another machine i tested)

I have a function that runs for about 0.7 seconds on my not-so-new develop machine. (it runs for about 3 seconds on another machine I tested)

i want to show the user some pre-message about half a second before the above function is done.

I want to show the user some pre-message about half a second before the above function is done.

i don't want to show the message too long before the function is done as it will be annoying to just look at it and wait...

I don't want to show the message too long before the function is done as it will be annoying to just look at it and wait...

on the other hand i rather not wait until the function is done because the whole thing starts from a user action and i don't want to "waste" time - it's better if i can show that message while the other function is doing it's job.

On the other hand I rather not wait until the function is done because the whole thing starts from a user action and I don't want to "waste" time - it's better if I can show that message while the other function is doing it's job.

I've already added a loop with a short Thread.sleep() to let the pre-message hang if the function was "too fast" but i'm affried that usually wont be the case...

I've already added a loop with a short Thread.sleep() to let the pre-message hang if the function was "too fast" but I'm afraid that usually wont be the case...

And so.... i want to see if i could roughly estimate the execution time base on current machine specifications and even by the current cpu usage. and do that before running the function.

And so.... I want to see if I could roughly estimate the execution time base on current machine specifications and even by the current CPU usage. and do that before running the function.

also since we are talking about seconds and milliseconds, if getting this information will take more the a few milliseconds then it's not worth it... in this case i might calculate it only once when the application is loaded

Also since we are talking about seconds and milliseconds, if getting this information will take more the a few milliseconds then it's not worth it... in this case I might calculate it only once when the application is loaded.

anybody has an idea how to do that?

Anybody has an idea how to do that?

Thanks alot

Thanks alot


i have a function that runs for about 0.7 seconds on my not-so-new develop machine. (it runs for about 3 seconds on another machine i tested)
i want to show the user some pre-message about half a second before the above function is done.
i don't want to show the message too long before the function is done as it will be annoying to just look at it and wait...
on the other hand i rather not wait until the function is done because the whole thing starts from a user action and i don't want to "waste" time - it's better if i can show that message while the other function is doing it's job.
I've already added a loop with a short Thread.sleep() to let the pre-message hang if the function was "too fast" but i'm affried that usually wont be the case...
And so.... i want to see if i could roughly estimate the execution time base on current machine specifications and even by the current cpu usage. and do that before running the function.
also since we are talking about seconds and milliseconds, if getting this information will take more the a few milliseconds then it's not worth it... in this case i might calculate it only once when the application is loaded
anybody has an idea how to do that?
Thanks alot

I have a function that runs for about 0.7 seconds on my not-so-new develop machine. (it runs for about 3 seconds on another machine I tested)

I want to show the user some pre-message about half a second before the above function is done.

I don't want to show the message too long before the function is done as it will be annoying to just look at it and wait...

On the other hand I rather not wait until the function is done because the whole thing starts from a user action and I don't want to "waste" time - it's better if I can show that message while the other function is doing it's job.

I've already added a loop with a short Thread.sleep() to let the pre-message hang if the function was "too fast" but I'm afraid that usually wont be the case...

And so.... I want to see if I could roughly estimate the execution time base on current machine specifications and even by the current CPU usage. and do that before running the function.

Also since we are talking about seconds and milliseconds, if getting this information will take more the a few milliseconds then it's not worth it... in this case I might calculate it only once when the application is loaded.

Anybody has an idea how to do that?

Thanks alot

Source Link
Ron K
  • 109
  • 1
  • 9

estimate execution time before running a function


i have a function that runs for about 0.7 seconds on my not-so-new develop machine. (it runs for about 3 seconds on another machine i tested)
i want to show the user some pre-message about half a second before the above function is done.
i don't want to show the message too long before the function is done as it will be annoying to just look at it and wait...
on the other hand i rather not wait until the function is done because the whole thing starts from a user action and i don't want to "waste" time - it's better if i can show that message while the other function is doing it's job.
I've already added a loop with a short Thread.sleep() to let the pre-message hang if the function was "too fast" but i'm affried that usually wont be the case...
And so.... i want to see if i could roughly estimate the execution time base on current machine specifications and even by the current cpu usage. and do that before running the function.
also since we are talking about seconds and milliseconds, if getting this information will take more the a few milliseconds then it's not worth it... in this case i might calculate it only once when the application is loaded
anybody has an idea how to do that?
Thanks alot