Determine How Much Time Has Passed

I’m trying to determine how long a “job” takes.

@job is an instance of the ActiveRecord model.

job_time = (Time.now.utc - @job.created_at.utc)/1.minute

I am using the “created_at” that comes with ActiveRecord.

Since Time.now is not utc and @job.created_at is “UTC” (all caps), I
converted both to utc to get consistent results.

  1. job_time is in minutes, correct?
  2. Any issues with computing job_time this way to get minutes?

Couldn’t you use benchmark?

Ivan L. wrote in post #1182107:

Couldn’t you use benchmark?
http://ruby-doc.org/stdlib-1.9.3/libdoc/benchmark/rdoc/Benchmark.h

Can’t require any modules. Need to compute using basic stuff.

Ronald F. wrote in post #1182206:

Jan Yo wrote in post #1182191:

Ivan L. wrote in post #1182107:

Couldn’t you use benchmark?
http://ruby-doc.org/stdlib-1.9.3/libdoc/benchmark/rdoc/Benchmark.h

Can’t require any modules. Need to compute using basic stuff.

As you can see from the link, Benchmark is part of the standard
library, and part of the Ruby installation. No need to install anything.

Okay, cool, didn’t know that.

Jan Yo wrote in post #1182191:

Ivan L. wrote in post #1182107:

Couldn’t you use benchmark?
http://ruby-doc.org/stdlib-1.9.3/libdoc/benchmark/rdoc/Benchmark.h

Can’t require any modules. Need to compute using basic stuff.

As you can see from the link, Benchmark is part of the standard
library, and part of the Ruby installation. No need to install anything.