Project

General

Profile

Actions

Feature #8640

open

Add Time#elapsed to return nanoseconds since creation

Added by tenderlovemaking (Aaron Patterson) almost 11 years ago. Updated over 2 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:56027]

Description

Hi,

We time many things in Rails (and so does lots of other code), and I've found that we spend lots of time allocating and subtracting time objects. For example:

start = Time.now

do stuff we want to time

finish = Time.now - start

It would be nice if we could just create one time object and grab the nanoseconds elapsed since the time object was created like so:

start = Time.now

do stuff we want to time

finished = start.elapsed # => nanoseconds elapsed.

I've attached a patch that implements this feature.


Files

elapsed.patch (1.95 KB) elapsed.patch tenderlovemaking (Aaron Patterson), 07/16/2013 03:39 AM

Related issues 3 (1 open2 closed)

Related to Ruby master - Feature #8658: Process.clock_gettimeClosed07/19/2013Actions
Related to Ruby master - Feature #8096: introduce Time.current_timestampFeedbackmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Feature #12173: `Time#till_now`OpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0