From 91d3bc66c82d2077f6aae79b61cc2f0642197a66 Mon Sep 17 00:00:00 2001 From: javi Date: Thu, 20 Oct 2011 16:46:39 +0200 Subject: [PATCH] trying to avoid precision problems with small time measures --- lib/cartodb/tile_cache.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/cartodb/tile_cache.js b/lib/cartodb/tile_cache.js index bec60e70..b4c3a3f5 100644 --- a/lib/cartodb/tile_cache.js +++ b/lib/cartodb/tile_cache.js @@ -55,7 +55,7 @@ function GenericCache (cache_policy, cache_validator) { } me.beforeTileRender = function(req, res, callback) { - req.windshaft_start = new Date().getTime()/1000.0; + req.windshaft_start = new Date().getTime(); var key = cache_key(req); var tile = me.cache.get(key); if(tile) { @@ -67,9 +67,9 @@ function GenericCache (cache_policy, cache_validator) { callback(null); } else { me.cache_hits++; - var timestamp = new Date().getTime()/1000.0; + var timestamp = new Date().getTime(); var delta = timestamp - req.windshaft_start; - tile.cache_time = delta; + tile.cache_time = delta/1000.0; tile.hits++; res.header('X-Cache-hit', 'true'); res.send(tile.tile, tile.headers, 200); @@ -82,13 +82,13 @@ function GenericCache (cache_policy, cache_validator) { } me.afterTileRender = function(req, res, tile, headers, callback) { - var timestamp = new Date().getTime()/1000.0; + var timestamp = new Date().getTime(); var delta = timestamp - req.windshaft_start; me.cache.put(cache_key(req), { tile: tile, headers: headers, timestamp: timestamp, - render_time: delta, + render_time: delta/1000.0, hits: 0}); update_items(me.cache.size || 0); callback(null, tile, headers);