<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>zwyan2009 (鄢章武)</title>
    <link>https://ruby-china.org/zwyan2009</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Time.now.at_beginning_of_month 耗时问题</title>
      <description>&lt;p&gt;最近遇到个诡异的问题。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;本机 mac 10.9  ruby 2.2.0 Rails 4.2.0&lt;/strong&gt;
  costs = Benchmark.realtime {Time.now.at_beginning_of_month} *1000
  =&amp;gt; 0.0939369201660156&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;服务器 Ubuntu 12.04 ruby 2.2.0 Rails 4.2.0&lt;/strong&gt;
costs = Benchmark.realtime {Time.now.at_beginning_of_month} *1000
1.925826072692871&lt;/p&gt;

&lt;p&gt;两者时间相差太大，服务器上此方法耗时太长，而且代码中使用了大量这样的代码。影响性能。
各位大牛有没有什么思路。&lt;/p&gt;

&lt;p&gt;注：各位机器上的耗时是多少啊？&lt;/p&gt;</description>
      <author>zwyan2009</author>
      <pubDate>Mon, 09 Feb 2015 10:22:00 +0800</pubDate>
      <link>https://ruby-china.org/topics/24174</link>
      <guid>https://ruby-china.org/topics/24174</guid>
    </item>
  </channel>
</rss>
