Project

General

Profile

Actions

Feature #8640

open

Add Time#elapsed to return nanoseconds since creation

Added by tenderlovemaking (Aaron Patterson) about 8 years ago. Updated about 8 years ago.

Status:
Open
Priority:
Normal
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

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

Also available in: Atom PDF