How do I get elapsed time in milliseconds in Ruby?

前端 未结 10 2177
走了就别回头了
走了就别回头了 2020-12-13 05:27

If I have a Time object got from :

Time.now

and later I instantiate another object with that same line, how can I see how many

10条回答
  •  别那么骄傲
    2020-12-13 05:51

    Time.now.to_f can help you but it returns seconds.

    In general, when working with benchmarks I:

    • put in variable the current time;
    • insert the block to test;
    • put in a variable the current time, subtracting the preceding current-time value;

    It's a very simple process, so I'm not sure you were really asking this...

提交回复
热议问题