From: "headius (Charles Nutter)" Date: 2013-03-15T15:07:23+09:00 Subject: [ruby-core:53434] [CommonRuby - Feature #8096] introduce Time.current_timestamp Issue #8096 has been updated by headius (Charles Nutter). This is an *excellent* idea. Being able to get timestamps without creating an entire Time object would be really nice for code that does fine-grained timing. Here's a benchmark of Time.now.to_i compared to the Java method System.nanoTime (the simplest way on JVM to get a timestamp). https://gist.github.com/headius/5167793 Calculating ------------------------------------- Time.new.to_i 106740 i/100ms System.nanoTime 187876 i/100ms ------------------------------------------------- Time.new.to_i 5457230.7 (��7.3%) i/s - 27111960 in 5.000000s System.nanoTime 17952011.5 (��9.2%) i/s - 88301720 in 4.976000s Given that nanoTime likely makes the same native call this feature would, we could see a similar improvement if such a feature were standard. May I suggest "Time.timestamp" instead? Do people really want timestamps that aren't "current"? ---------------------------------------- Feature #8096: introduce Time.current_timestamp https://bugs.ruby-lang.org/issues/8096#change-37620 Author: vipulnsward (Vipul Amler) Status: Open Priority: Low Assignee: Category: Target version: =begin A lot of scenarios and applications require the use of Time.now.to_i which is used as current_timestamp in systems. The introduction of Time.current_timestamp {or something with similar with different name} would provide implicit integer timestamp instead of going from Time.now -> time_object -> to_i -> integer timestamp value So instead of (({> Time.now.to_i # Outputs => 1363274618})) one could use (({> Time.current_timestamp # Outputs => 1363274618})) =end -- http://bugs.ruby-lang.org/