Git Product home page Git Product logo

Comments (6)

catuhana avatar catuhana commented on June 20, 2024

Apparently, that doesn't just happen with compile, but every time when Deno caches dependencies and shows their progress.

from deno.

bartlomieju avatar bartlomieju commented on June 20, 2024

Per std::time::SystemTime::elapsed docs:

Returns the difference from this system time to the current clock time.

This function may fail as the underlying system clock is susceptible to drift and updates (e.g., the system clock could go backwards), so this function might not always succeed. If successful, Ok(Duration) is returned where the duration represents the amount of time elapsed from this time measurement to the current time.

We should probably remove .unwrap() there and default to 0s duration there.

from deno.

catuhana avatar catuhana commented on June 20, 2024

Per std::time::SystemTime::elapsed docs:

Returns the difference from this system time to the current clock time.
This function may fail as the underlying system clock is susceptible to drift and updates (e.g., the system clock could go backwards), so this function might not always succeed. If successful, Ok(Duration) is returned where the duration represents the amount of time elapsed from this time measurement to the current time.

We should probably remove .unwrap() there and default to 0s duration there.

If defaulting to 0 is enough, I can create a PR for it!

from deno.

catuhana avatar catuhana commented on June 20, 2024

Also, it seems like docs are recommending to use Instant instead.

To measure elapsed time reliably, use Instant instead.

But Instant also has this note:

Note, however, that instants are not guaranteed to be steady. In other words, each tick of the underlying clock might not be the same length (e.g. some seconds may be longer than others). An instant may jump forwards or experience time dilation (slow down or speed up), but it will never go backwards. As part of this non-guarantee it is also not specified whether system suspends count as elapsed time or not. The behavior varies across platforms and rust versions.

Instants are opaque types that can only be compared to one another. There is no method to get โ€œthe number of secondsโ€ from an instant. Instead, it only allows measuring the duration between two instants (or comparing two instants).

Would using Instant instead of SystemTime change the intended behaviour?

from deno.

bartlomieju avatar bartlomieju commented on June 20, 2024

@catuhana yes, that would work as well. This field is used for a very non-essential functionality that doesn't need to display very precise data, so anything that removes a potential panic is a good fix ๐Ÿ‘

from deno.

catuhana avatar catuhana commented on June 20, 2024

Alright, thanks!

from deno.

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.