Giter VIP home page Giter VIP logo

Comments (6)

lrq3000 avatar lrq3000 commented on May 10, 2024

So, to summary, we need a way to measure CPU time (process-wide time = relative time since process started) instead of system-wide, absolute time. This is well explained in this SO answer.

[Relative time is a ] type of time that has no defined relationship to real-world time, in the sense that the relationship is system and implementation specific. It can be used only to measure time intervals, i.e. a unit-less value which is proportional to the time elapsed between two instants. This is mainly used to evaluate relative performance (e.g. whether this version of code runs faster than that version of code).

To achieve that, the best candidate seems to be time.monotonic() which has the advantage of being monotonic, which means that the time can't go backward. Unfortunately, on recent OSes, it has become system-wide, so we cannot use that.

The second best candidate is time.process_time(), and it has all the criteria. However, it's only available on Python 3.3+, and it seems there's no backward port yet using __future__.

However, there is also time.clock(), which is process-wide. But there are 3 issues:

1- time resolution differs between Windows and Linux.
2- works differently on Windows and Linux (ie, on Linux it works just like time.time(), but on Windows it will return the difference since the first call to time.clock()).
3- It has been deprecated in Python 3.3+.

So I guess we want to use process_time() on Python 3.3+, and use time.clock() on Python 2, and we have to try to manage manually the difference of usage between Windows and Linux.

from tqdm.

lrq3000 avatar lrq3000 commented on May 10, 2024

Note that because of time.clock(), we may also have to make some tests slower in order for time.clock() to have enough resolution to time them...

from tqdm.

lrq3000 avatar lrq3000 commented on May 10, 2024

PS: there ARE implementations of monotonic time for previous versions of Python, but they all require either compilation of c files, or using ctypes:

from tqdm.

lrq3000 avatar lrq3000 commented on May 10, 2024

I added relative timing for all the tests that required it. I did have to add a new internal parameter in tqdm class to support relative timing directly inside tqdm (I hope that's OK, because I couldn't think of any more elegant solution...).

We should try out this PR by restarting several times the Travis build at different times of the day, just to ensure that all tests always pass.

from tqdm.

casperdcl avatar casperdcl commented on May 10, 2024

Hmm I think there may be a way to avoid the extra parameter... will look at this later

from tqdm.

lrq3000 avatar lrq3000 commented on May 10, 2024

@casperdcl Ok thank's.

About the PR, the perf test just failed, the manually updated tqdm took way much longer than usual. So this PR doesn't completely fix the issue... But it seems it still somewhat helps.

from tqdm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.