Reports the memory usage of the resolved tiles in the current scene block.
433972
public void reportMemoryUsage ()
    {
        Map<Tile.Key,BaseTile> base = Maps.newHashMap();
        Set<BaseTile> fringe = Sets.newHashSet();
        Map<Tile.Key,ObjectTile> object = Maps.newHashMap();
        long[] usage = new long[3];
        for (SceneBlock block : _blocks.values()) {
            block.computeMemoryUsage(base, fringe, object, usage);
        }
        log.info("Scene tile memory usage",
            "scene", StringUtil.shortClassName(this),
            "base", base.size() + "->" + (usage[0] / 1024) + "k",
            "fringe", fringe.size() + "->" + (usage[1] / 1024) + "k",
            "obj", object.size() + "->" + (usage[2] / 1024) + "k");
    }
66739
def trace_memory_usage(self, frame, event, arg):
        """"""
        if (event in ('call', 'line', 'return')
                and frame.f_code in self.code_map):
            if event != 'call':
                # "call" event just saves the lineno but not the memory
                mem = _get_memory(-1, include_children=self.include_children)
                # if there is already a measurement for that line get the max
                old_mem = self.code_map[frame.f_code].get(self.prevline, 0)
                self.code_map[frame.f_code][self.prevline] = max(mem, old_mem)
            self.prevline = frame.f_lineno

        if self._original_trace_function is not None:
            (self._original_trace_function)(frame, event, arg)

        return self.trace_memory_usage
444954
def _flush_tile_queue(self, surface):
        
        tw, th = self.data.tile_size
        ltw = self._tile_view.left * tw
        tth = self._tile_view.top * th
        surface_blit = surface.blit

        self.data.prepare_tiles(self._tile_view)

        for x, y, l, image in self._tile_queue:
            surface_blit(image, (x * tw - ltw, y * th - tth))
998359
function () {
            var hash = me.utils.getUriFragment();

            // add a few new debug flag (if not yet defined)
            me.debug.renderHitBox   = me.debug.renderHitBox   || hash.hitbox || false;
            me.debug.renderVelocity = me.debug.renderVelocity || hash.velocity || false;
            me.debug.renderQuadTree = me.debug.renderQuadTree || hash.quadtree || false;

            var _this = this;
            var bounds = new me.Rect(0, 0, 0, 0);

            // patch me.game.update
            me.plugin.patch(me.game, "update", function (dt) {
                var frameUpdateStartTime = window.performance.now();

                this._patched.apply(this, arguments);

                // calculate the update time
                _this.frameUpdateTime = window.performance.now() - frameUpdateStartTime;
            });

            // patch me.game.draw
            me.plugin.patch(me.game, "draw", function () {
                var frameDrawStartTime = window.performance.now();

                _this.counters.reset();

                this._patched.apply(this, arguments);

                // calculate the drawing time
                _this.frameDrawTime = window.performance.now() - frameDrawStartTime;
            });

            // patch sprite.js
            me.plugin.patch(me.Sprite, "draw", function (renderer) {

                // call the original me.Sprite.draw function
                this._patched(renderer);

                // don't do anything else if the panel is hidden
                if (_this.visible) {

                    // increment the sprites counter
                    _this.counters.inc("sprites");

                    // draw the sprite rectangle
                    if (me.debug.renderHitBox) {
                        var bounds = this.getBounds();
                        var ax = this.anchorPoint.x * bounds.width,
                            ay = this.anchorPoint.y * bounds.height;

                        var ancestor = this.ancestor;
                        if (ancestor instanceof me.Container && ancestor.root === false) {
                            ax -= ancestor._absPos.x;
                            ay -= ancestor._absPos.y;
                        } else if (ancestor instanceof me.Entity) {
                            ancestor = ancestor.ancestor;
                            if (ancestor instanceof me.Container && ancestor.root === false) {
                                // is this correct ???
                                ax = ay = 0;
                            }
                        }

                        // translate back as the bounds position
                        // is already adjusted to the anchor Point
                        renderer.translate(ax, ay);

                        renderer.setColor("green");
                        renderer.stroke(bounds);

                        renderer.translate(-ax, -ay);

                        // the sprite mask if defined
                        if (typeof this.mask !== "undefined") {
                            renderer.setColor("orange");
                            renderer.stroke(this.mask);
                        }

                        if (typeof this.body !== "undefined") {
                            renderer.translate(this.pos.x, this.pos.y);
                            // draw all defined shapes
                            renderer.setColor("red");
                            for (var i = this.body.shapes.length, shape; i--, (shape = this.body.shapes[i]);) {
                                renderer.stroke(shape);
                                _this.counters.inc("shapes");
                            }
                        }
                    }
                }
            });


            me.plugin.patch(me.BitmapText, "draw", function (renderer) {
                // call the original me.Sprite.draw function
                this._patched.apply(this, arguments);

                // draw the font rectangle
                if (_this.visible && me.debug.renderHitBox && this.name !== "debugPanelFont") {
                    var bounds = this.getBounds();

                    if (typeof this.ancestor !== "undefined") {
                        var ax = this.anchorPoint.x * bounds.width,
                            ay = this.anchorPoint.y * bounds.height;
                        // translate back as the bounds position
                        // is already adjusted to the anchor Point
                        renderer.translate(ax, ay);
                    } else {
                        renderer.save();
                    }

                    renderer.setColor("orange");
                    renderer.stroke(bounds);
                    _this.counters.inc("bounds");

                    if (typeof this.ancestor === "undefined") {
                        renderer.restore();
                    }
                }
            });

            // patch font.js
            me.plugin.patch(me.Text, "draw", function (renderer, text, x, y) {
                // call the original me.Text.draw function
                this._patched.apply(this, arguments);

                // call the original me.Sprite.draw function
                if (_this.visible && me.debug.renderHitBox) {
                    if (typeof this.ancestor === "undefined") {
                        renderer.save();
                    }
                    renderer.setColor("orange");
                    renderer.stroke(this.getBounds());
                    _this.counters.inc("bounds");
                    if (typeof this.ancestor === "undefined") {
                        renderer.restore();
                    }
                }
            });

            // patch font.js
            me.plugin.patch(me.Text, "drawStroke", function (renderer, text, x, y) {
                // call the original me.Font.drawStroke function
                this._patched.apply(this, arguments);

                // draw the font rectangle
                if (_this.visible && me.debug.renderHitBox) {
                    if (typeof this.ancestor === "undefined") {
                        renderer.save();
                    }
                    renderer.setColor("orange");
                    renderer.stroke(this.getBounds());
                    _this.counters.inc("bounds");
                    if (typeof this.ancestor === "undefined") {
                        renderer.restore();
                    }
                }
            });

            // patch entities.js
            me.plugin.patch(me.Entity, "postDraw", function (renderer) {
                // don't do anything else if the panel is hidden
                if (_this.visible) {
                    // increment the bounds counter
                    _this.counters.inc("bounds");

                    // check if debug mode is enabled
                    if (me.debug.renderHitBox) {
                        renderer.save();

                        renderer.translate(
                            -this.pos.x - this.body.pos.x - this.ancestor._absPos.x,
                            -this.pos.y - this.body.pos.y - this.ancestor._absPos.y
                        );

                        if (this.renderable instanceof me.Renderable) {
                            renderer.translate(
                                -this.anchorPoint.x * this.body.width,
                                -this.anchorPoint.y * this.body.height
                            );
                        }

                        // draw the bounding rect shape
                        renderer.setColor("orange");
                        renderer.stroke(this.getBounds());

                        renderer.translate(
                            this.pos.x + this.ancestor._absPos.x,
                            this.pos.y + this.ancestor._absPos.y
                        );

                        // draw all defined shapes
                        renderer.setColor("red");
                        for (var i = this.body.shapes.length, shape; i--, (shape = this.body.shapes[i]);) {
                            renderer.stroke(shape);
                            _this.counters.inc("shapes");
                        }
                        renderer.restore();
                    }

                    if (me.debug.renderVelocity && (this.body.vel.x || this.body.vel.y)) {
                        bounds.copy(this.getBounds());
                        bounds.pos.sub(this.ancestor._absPos);
                        // draw entity current velocity
                        var x = bounds.width / 2;
                        var y = bounds.height / 2;

                        renderer.save();
                        renderer.setLineWidth(1);

                        renderer.setColor("blue");
                        renderer.translate(-x, -y);
                        renderer.strokeLine(0, 0, ~~(this.body.vel.x * (bounds.width / 2)), ~~(this.body.vel.y * (bounds.height / 2)));
                        _this.counters.inc("velocity");

                        renderer.restore();
                    }
                }
                // call the original me.Entity.postDraw function
                this._patched.apply(this, arguments);
            });

            // patch container.js
            me.plugin.patch(me.Container, "draw", function (renderer, rect) {
                // call the original me.Container.draw function
                this._patched.apply(this, arguments);

                // check if debug mode is enabled
                if (!_this.visible) {
                    // don't do anything else if the panel is hidden
                    return;
                }

                // increment counters
                _this.counters.inc("bounds");
                _this.counters.inc("children");

                if (me.debug.renderHitBox) {
                    renderer.save();
                    renderer.setLineWidth(1);

                    if (!this.root) {
                        renderer.translate(
                            -this._absPos.x,
                            -this._absPos.y
                        );
                    }

                    // draw the bounding rect shape
                    renderer.setColor("orange");
                    renderer.stroke(this.getBounds());

                    // draw the children bounding rect shape
                    renderer.setColor("purple");
                    renderer.stroke(this.childBounds);

                    renderer.restore();
                }
            });
        }
393085
private void cutCurrentCache() {

		final File lock=Configuration.getInstance().getOsmdroidTileCache();
		synchronized (lock) {

			if (mUsedCacheSpace > Configuration.getInstance().getTileFileSystemCacheTrimBytes()) {

				Log.d(IMapView.LOGTAG,"Trimming tile cache from " + mUsedCacheSpace + " to "
						+ Configuration.getInstance().getTileFileSystemCacheTrimBytes());

				final List<File> z = getDirectoryFileList(Configuration.getInstance().getOsmdroidTileCache());

				// order list by files day created from old to new
				final File[] files = z.toArray(new File[0]);
				Arrays.sort(files, new Comparator<File>() {
					@Override
					public int compare(final File f1, final File f2) {
						return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
					}
				});

				for (final File file : files) {
					if (mUsedCacheSpace <= Configuration.getInstance().getTileFileSystemCacheTrimBytes()) {
						break;
					}

					final long length = file.length();
					if (file.delete()) {
						if (Configuration.getInstance().isDebugTileProviders()){
							Log.d(IMapView.LOGTAG,"Cache trim deleting " + file.getAbsolutePath());
						}
						mUsedCacheSpace -= length;
					}
				}

				Log.d(IMapView.LOGTAG,"Finished trimming tile cache");
			}
		}
	}
989889
function(prepareTiles, rendererHelper,
        visited, flowEvents, sortedRasterizerSlices) {
      if (!prepareTiles.args.prepare_tiles_id)
        return;

      if (!rendererHelper || !rendererHelper.rasterWorkerThreads)
        return;

      var rasterWorkerThreads = rendererHelper.rasterWorkerThreads;
      var prepare_tile_id = prepareTiles.args.prepare_tiles_id;
      var pendingEventQueue = [];

      // Collect all the rasterizer tasks. Return the cached copy if possible.
      if (sortedRasterizerSlices.length === 0)
        this.sortRasterizerSlices(rasterWorkerThreads, sortedRasterizerSlices);

      // TODO(yuhao): Once TaskSetFinishedTaskImpl also get the prepare_tile_id
      // we can simply track by checking id rather than counting.
      var numFinishedTasks = 0;
      var RASTER_TASK_TITLE = 'RasterizerTaskImpl::RunOnWorkerThread';
      var IMAGEDECODE_TASK_TITLE = 'ImageDecodeTaskImpl::RunOnWorkerThread';
      var FINISHED_TASK_TITLE = 'TaskSetFinishedTaskImpl::RunOnWorkerThread';

      for (var i = 0; i < sortedRasterizerSlices.length; i++) {
        var task = sortedRasterizerSlices[i];

        if (task.title === RASTER_TASK_TITLE ||
            task.title === IMAGEDECODE_TASK_TITLE) {
          if (task.args.source_prepare_tiles_id === prepare_tile_id)
            this.addEntireSliceHierarchy(task.mostTopLevelSlice);
        } else if (task.title === FINISHED_TASK_TITLE) {
          if (task.start > prepareTiles.start) {
            pendingEventQueue.push(task.mostTopLevelSlice);
            if (++numFinishedTasks === 3)
              break;
          }
        }
      }

      // Trace PostTask from rasterizer tasks.
      while (pendingEventQueue.length != 0) {
        var event = pendingEventQueue.pop();

        this.addEntireSliceHierarchy(event);
        this.followSubsequentSlices(event, pendingEventQueue, visited,
            flowEvents);
      }
    }
114430
function() {
        this.matrix = this.getMatrix();
        if (this.matrix) {
            if (this.matrix.topLeftCorner) {
                this.tileOrigin = this.matrix.topLeftCorner;
            }
            if (this.matrix.tileWidth && this.matrix.tileHeight) {
                this.tileSize = new OpenLayers.Size(
                    this.matrix.tileWidth, this.matrix.tileHeight
                );
            }
            if (!this.tileOrigin) { 
                this.tileOrigin = new OpenLayers.LonLat(
                    this.maxExtent.left, this.maxExtent.top
                );
            }   
            if (!this.tileFullExtent) { 
                this.tileFullExtent = this.maxExtent;
            }
        }
    }
206739
protected void checkMapSize()
  {
    if ((map instanceof EmbeddedSlotMap) && map.size() >= LARGE_HASH_SIZE) {
      SlotMap newMap = new HashSlotMap();
      for (Slot s : map) {
        newMap.addSlot(s);
      }
      map = newMap;
    }
  }
1242148
protected void reportCachePerformance ()
    {
        if (/* Log.getLevel() != Log.log.DEBUG || */
            _cacheStatThrottle.throttleOp()) {
            return;
        }

        // compute our estimated memory usage
        long size = 0;

        int[] eff = null;
        synchronized (_ccache) {
            Iterator<CacheRecord> iter = _ccache.values().iterator();
            while (iter.hasNext()) {
                size += iter.next().getEstimatedMemoryUsage();
            }
            eff = _ccache.getTrackedEffectiveness();
        }
        log.info("ImageManager LRU", "mem", ((size / 1024) + "k"), "size", _ccache.size(),
            "hits", eff[0], "misses", eff[1], "totalKeys", _keySet.size());
    }
1266647
function () {

            if (this.animatedTilesets === undefined) {
                this.animatedTilesets = [];
            }

            if (this.tilesets) {
                var tileset = this.tilesets.tilesets;
                for (var i = 0; i < tileset.length; i++) {
                    if (tileset[i].isAnimated) {
                        this.animatedTilesets.push(tileset[i]);
                    }
                }
            }

            this.isAnimated = this.animatedTilesets.length > 0;

            // Force pre-render off when tileset animation is used
            if (this.isAnimated) {
                this.preRender = false;
            }

            // Resize the bounding rect
            var bounds = this.getRenderer().getBounds(this);
            this.getBounds().resize(bounds.width, bounds.height);

            // if pre-rendering method is use, create an offline canvas/renderer
            if ((this.preRender === true) && (!this.canvasRenderer)) {
                this.canvasRenderer = new me.CanvasRenderer(
                    me.video.createCanvas(this.width, this.height),
                    this.width, this.height,
                    { transparent : true }
                );
            }
        }
673943
function(){
            this.fillBg();
            for (var x = this.width - 1; x >= 0; x--) {
                for (var y = this.height - 1; y >= 0; y--) {
                    // get the actual map tile coord from view coord using offset
                    var tileX = x + this.originX,
                        tileY = y + this.originY;
                    this.drawTile(tileX, tileY);
                }
            }

            this.drawBufferToCanvas();
        }
1052102
public void protectDisplayedTilesForCache(final Canvas pCanvas, final Projection pProjection) {
		if (!setViewPort(pCanvas, pProjection)) {
			return;
		}
		TileSystem.getTileFromMercator(mViewPort, TileSystem.getTileSize(mProjection.getZoomLevel()), mProtectedTiles);
		final int tileZoomLevel = TileSystem.getInputTileZoomLevel(mProjection.getZoomLevel());
		mTileProvider.getTileCache().getMapTileArea().set(tileZoomLevel, mProtectedTiles);
		mTileProvider.getTileCache().maintenance();
	}
423471
def bounds(ctx, tile):
    """"""
    click.echo(
        '%s %s %s %s' % TilePyramid(
            ctx.obj['grid'],
            tile_size=ctx.obj['tile_size'],
            metatiling=ctx.obj['metatiling']
        ).tile(*tile).bounds(pixelbuffer=ctx.obj['pixelbuffer'])
    )
144208
@Override
    public void monitor() {
        Runtime runtime = Runtime.getRuntime();

        double allocatedMemory = runtime.totalMemory() / (double) 1024;
        double freeMemory = runtime.freeMemory() / (double) 1024;

        double totalFreeMemory = freeMemory + (maxMemory - allocatedMemory);

        calculatedAllocatedMemory = allocatedMemory;
        calculatedFreeMemory = freeMemory;
        calculatedTotalFreeMemory = totalFreeMemory;

        this.percentageOfMemoryUsed = (((double) 100) - ((totalFreeMemory / maxMemory) * ((double) 100)));

        super.applyNewValue(memoryAlarmLevel, percentageOfMemoryUsed, memoryThreshold, backToNormalMemoryThreshold, true);
    }
987114
function( tiledImage ) {
        $.console.assert(tiledImage, '[TileCache.clearTilesFor] tiledImage is required');
        var tileRecord;
        for ( var i = 0; i < this._tilesLoaded.length; ++i ) {
            tileRecord = this._tilesLoaded[ i ];
            if ( tileRecord.tiledImage === tiledImage ) {
                this._unloadTile(tileRecord);
                this._tilesLoaded.splice( i, 1 );
                i--;
            }
        }
    }
1213818
def report(ctx, board, done, output):
    ctx.obj['board_id'] = board
    ts = TrelloStats(ctx.obj)
    
    ct = cycle_time(ts, board, done)
    env = get_env()

    #  Get all render functions from the module and filter out the ones we don't want.
    render_functions = [target for target in
                     dir(sys.modules['trellostats.reports'])
                     if target.startswith("render_") and
                     target.endswith(output)]
    
    for render_func in render_functions:
        print globals()[render_func](env, **dict(cycle_time=ct))
166901
function () {

            // Internal: intentionally not documented
            this.frameCount = 0;

            // Internal: intentionally not documented
            this.frameTimeCumulative = 0;

            // Internal: intentionally not documented
            this.frameTimeBase = 0;

            // Internal: intentionally not documented
            this.frameTimeExtremes = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY];

            /**
             * The number of milliseconds required to render the most recent frame.
             * @type {Number}
             */
            this.frameTime = 0;

            /**
             * The number of milliseconds spent tessellating the terrain during the most recent frame.
             * @type {Number}
             */
            this.tessellationTime = 0;

            /**
             * The number of milliseconds spent rendering the active layers during the most recent frame.
             * @type {Number}
             */
            this.layerRenderingTime = 0;

            /**
             * The number of milliseconds spent rendering ordered renderables during the most recent frame.
             * @type {Number}
             */
            this.orderedRenderingTime = 0;

            /**
             * The number of terrain tiles in the most recent frame.
             * @type {Number}
             */
            this.terrainTileCount = 0;

            /**
             * The number of image tiles in the most recent frame.
             * @type {Number}
             */
            this.imageTileCount = 0;

            /**
             * The number of terrain tile renderings. Since terrain tiles are generally rendered more than once per
             * frame, this count will be greater than the number of terrain tiles created for the frame.
             * @type {Number}
             */
            this.renderedTileCount = 0;

            /**
             * The number of calls to [Tile.update()]{@link Tile#update} during the most recent frame.
             * @type {Number}
             */
            this.tileUpdateCount = 0;

            /**
             * The number of texture bind calls during the most recent frame.
             * @type {Number}
             */
            this.textureLoadCount = 0;

            /**
             * The number of WebGL VBO loads during the most recent frame.
             * @type {Number}
             */
            this.vboLoadCount = 0;

            /**
             * The average frame time over the most recent two seconds.
             * @type {Number}
             */
            this.frameTimeAverage = 0;

            /**
             * The average frame rate over the most recent two seconds.
             * @type {Number}
             */
            this.frameRateAverage = 0;

            /**
             * The minimum frame time over the most recent two seconds.
             * @type {Number}
             */
            this.frameTimeMin = 0;

            /**
             * The maximum frame time over the most recent two seconds.
             * @type {Number}
             */
            this.frameTimeMax = 0;
        }