{"action":"opened","issue":{"url":"https://api.github.com/repos/fog/fog-core/issues/143","labels_url":"https://api.github.com/repos/fog/fog-core/issues/143/labels{/name}","comments_url":"https://api.github.com/repos/fog/fog-core/issues/143/comments","events_url":"https://api.github.com/repos/fog/fog-core/issues/143/events","html_url":"https://github.com/fog/fog-core/issues/143","id":65743344,"number":143,"title":"Fog::Time.now calling #to_i causes use of OpenStack mocks to be very slow","user":{"login":"drich10","id":3682728,"avatar_url":"https://avatars.githubusercontent.com/u/3682728?v=3","gravatar_id":"","url":"https://api.github.com/users/drich10","html_url":"https://github.com/drich10","followers_url":"https://api.github.com/users/drich10/followers","following_url":"https://api.github.com/users/drich10/following{/other_user}","gists_url":"https://api.github.com/users/drich10/gists{/gist_id}","starred_url":"https://api.github.com/users/drich10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drich10/subscriptions","organizations_url":"https://api.github.com/users/drich10/orgs","repos_url":"https://api.github.com/users/drich10/repos","events_url":"https://api.github.com/users/drich10/events{/privacy}","received_events_url":"https://api.github.com/users/drich10/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-01T17:59:37Z","updated_at":"2015-04-01T17:59:37Z","closed_at":null,"body":"This seems to cause an issue when attempting to run tests with Fog.mock! set. When Time.now is evaluated, it is only ever evaluated in full second intervals. Take this code block for example\r\n\r\n```\r\nFog::Mock.delay = 0\r\n\r\nserver.wait_for { ready? }\r\n.....\r\nclass Mock\r\n  def list_servers_detail(filters = {})\r\n    response = Excon::Response.new\r\n    servers = self.data[:servers].values\r\n    for server in servers\r\n      case server['status']\r\n        when 'BUILD'\r\n          if Time.now - self.data[:last_modified][:servers][server['id']] > Fog::Mock.delay * 2 [#1]\r\n            server['status'] = 'ACTIVE'\r\n          end\r\n        end\r\n      end\r\n\r\n    response.status = [200, 203][rand(1)]\r\n    response.body = { 'servers' => servers }\r\n    response\r\n  end\r\nend\r\n```\r\ndef list_servers_detail is invoked as part of the ready call in the server.wait_for block. Even with `Fog::Mock.delay =  0` `server.wait_for { ready? }` will take a full second to finish. This is because `Time.now -  self.data[:last_modified][:servers][server['id']]` will equal 0.0 until a full second has passed. We locally patched our tests to use `Time` instead of `Fog::Time` and our tests no longer took a performance hit on this line. Can `Time.now` be a float instead of an [integer](https://github.com/fog/fog-core/blob/master/lib/fog/core/time.rb#L9)?\r\n\r\nRegards,\r\nDerek, @wschaefer, @ryantang"}}