Skip to content

Enhance cv::TickMeter to be able to get the last elapsed time#26212

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
jamacias:feature/TickMeter-lasttime
Oct 14, 2024
Merged

Enhance cv::TickMeter to be able to get the last elapsed time#26212
asmorkalov merged 1 commit intoopencv:4.xfrom
jamacias:feature/TickMeter-lasttime

Conversation

@jamacias
Copy link
Copy Markdown
Contributor

@jamacias jamacias commented Sep 28, 2024

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • [N/A] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Proposal

This PR introduces a new interface to collect the last iteration time of the cv::TickMeter class.
Besides, two more minor changes are included:

  1. Reorder the variables inside the cv::TickeMeter::reset() method so that the order matches the declaration of the variables, which makes visual inspection easier.
  2. const correctness inside the cv::TickMeter::stop() method.

Motivation

When using the cv::TickMeter in a loop or in a continuous processing application, it is sometimes useful to also know the time that the last iteration took, not only the average. For example, if the user wants to report extraordinary deviations from the average, or to debug the application.

In this use case, the current implementation requires that the user implements complicated code externally that could be simply provided by the class in a more elegant way.

Related work

#6821 - Addition of the cv::TickMeter class.
#17071 - Addition of methods to get the FPS and average time to the cv::TickMeter class.

Other

I could not find any tests for the cv::TickMeter class. Now that there is increasingly more functionality, not sure if it may now be desirable to start testing this class. I could do so, if desired. We could test:

  1. The consistency between the several getters in different units (i.e., that micro is milli * 1e3, etc.).
  2. That in the first iteration the last iteration needs to be equal to the total time.
  3. Any other ideas?

This is my very first PR and I have read over the different documents on how to contribute. I hope I did not miss any detail, but let me know otherwise :)

@jamacias
Copy link
Copy Markdown
Contributor Author

jamacias commented Oct 10, 2024

I am a bit lost about what is going on with the different CI/CD pipelines. On the first commit I made, some jobs in the GitHub actions failed because of a timeout. Similarly, one of the builds of the PR bot also failed because of the same reason, and the other one reported a failure in the Compare ABI dumps step but somehow still marked it as OK (https://pullrequest.opencv.org/buildbot/builders/precommit_linux64/builds/109089).

Since I suspected that these complains could be unrelated to my changes, I made an empty commit just to trigger the pipelines and then I got everything OK except the Android-Test which again failed with:

This request was automatically failed because there were no enabled runners online to process the request for more than 1 days.

I have now reverted the second commit so that the history is clean, which will trigger another build, but I am wondering what to do to get this through. So far it seems not very deterministic since for the same code changes I get different results, which leads me to think this may be related to the infrastructure and not the changes (i.e., no enabled runners online or the timeouts). I also do not have macOS/Android device I can try the changes on.

I don't know if I am missing something. Could someone please give me some hints? Maybe @opencv-alalek or @asmorkalov know?

Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asmorkalov asmorkalov self-assigned this Oct 14, 2024
@asmorkalov asmorkalov merged commit 1909ac8 into opencv:4.x Oct 14, 2024
@asmorkalov asmorkalov mentioned this pull request Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants