How to use the @here/harp-utils.PerformanceTimer.now function in @here/harp-utils

To help you get started, we’ve selected a few @here/harp-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heremaps / harp.gl / @here / harp-mapview / lib / geometry / PhasedTileGeometryLoader.ts View on Github external
disabledKinds
            );
            tile.clear();
        }

        if (decodedTile === undefined || currentPhase >= this.numberOfPhases) {
            return false;
        }

        const geometryCreator = TileGeometryCreator.instance;

        const stats = PerformanceStatistics.instance;
        let now = 0;

        if (stats.enabled) {
            now = PerformanceTimer.now();
        }

        if (doFullUpdate) {
            geometryCreator.createAllGeometries(tile, decodedTile);

            // Mark it as finished.
            this.m_currentPhaseIndex = loadPhaseDefinitions.length;
        } else {
            const currentPhaseDefinition = loadPhaseDefinitions[currentPhase];

            for (const kind of currentPhaseDefinition) {
                this.createKind(geometryCreator, kind);
            }
        }

        if (stats.enabled) {
github heremaps / harp.gl / @here / harp-examples / lib / PerformanceUtils.ts View on Github external
decoderCount?: number,
        phasedLoading?: boolean,
        powerPreference?: MapViewPowerPreference,
        storageLevelOffsetModifier: number = 0,
        theme: ThemeDef = DEFAULT_THEME
    ): Promise {
        const mapViewApp = initializeMapViewApp(
            id,
            decoderCount,
            phasedLoading,
            powerPreference,
            theme
        );

        // Store time MapView has been initialized
        const appInitTime = PerformanceTimer.now();

        // Set to `true` to visualize the text placement collisions
        debugContext.setValue("DEBUG_SCREEN_COLLISIONS", false);

        return new Promise((resolve, reject) => {
            const dataSourceInitialized = connectDataSources(
                mapViewApp,
                dataSourceType,
                storageLevelOffsetModifier
            );

            dataSourceInitialized
                .then(() => {
                    PerformanceStatistics.instance.appResults.set("startTime", appStartTime);
                    PerformanceStatistics.instance.appResults.set("initTime", appInitTime);
                    resolve(mapViewApp);
github heremaps / harp.gl / @here / harp-mapview / lib / Statistics.ts View on Github external
start(): number {
        if (!this.statistics.enabled) {
            return -1;
        }
        if (this.running) {
            throw new Error("Timer '" + this.name + "' is already running");
        }
        this.running = true;
        return (this.m_currentValue = PerformanceTimer.now());
    }
github heremaps / harp.gl / @here / harp-examples / lib / PerformanceUtils.ts View on Github external
firstLocation.zoomLevel,
            0,
            firstLocation.tilt,
            true
        );

        await ensureRenderFinished(mapViewApp);

        await delay(1000);

        let currentFrameNumber = 0;
        const newStats = new PerformanceStatistics(
            true,
            waitForFrameLoaded ? locations.length : locations.length * 2
        );
        const startTime = PerformanceTimer.now();

        return new Promise((resolve, reject) => {
            const renderCallback = () => {
                if (isCancelled !== undefined && isCancelled()) {
                    mapView.endAnimation();
                    mapView.removeEventListener(MapViewEventNames.AfterRender, renderCallback);
                    resolve(undefined);
                }

                if (waitForFrameLoaded && MapViewUtils.mapViewIsLoading(mapViewApp.mapView)) {
                    mapViewApp.mapView.update();
                } else if (currentFrameNumber >= locations.length) {
                    mapView.removeEventListener(MapViewEventNames.AfterRender, renderCallback);

                    const totalTime = PerformanceTimer.now() - startTime;
                    newStats.appResults.set("flyoverFPS", (1000 * currentFrameNumber) / totalTime);
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecoder.ts View on Github external
styleSetEvaluator,
            this.m_showMissingTechniques,
            this.m_featureFilter,
            this.m_featureModifier,
            this.m_gatherFeatureAttributes,
            this.m_createTileInfo,
            this.m_gatherRoadSegments,
            this.m_skipShortLabels,
            this.m_storageLevelOffset,
            this.m_enableElevationOverlay,
            this.languages
        );

        const tileInfo = decoder.getTileInfo(tileKey, data);

        tileInfo.setupTime = PerformanceTimer.now() - startTime;

        return Promise.resolve(tileInfo);
    }
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecoder.ts View on Github external
decodeThemedTile(
        data: ArrayBufferLike,
        tileKey: TileKey,
        styleSetEvaluator: StyleSetEvaluator,
        projection: Projection
    ): Promise {
        const startTime = PerformanceTimer.now();

        const decoder = new OmvDecoder(
            projection,
            styleSetEvaluator,
            this.m_showMissingTechniques,
            this.m_featureFilter,
            this.m_featureModifier,
            this.m_gatherFeatureAttributes,
            this.m_createTileInfo,
            this.m_gatherRoadSegments,
            this.m_skipShortLabels,
            this.m_storageLevelOffset,
            this.m_enableElevationOverlay,
            this.languages
        );
github heremaps / harp.gl / @here / harp-mapview / lib / Statistics.ts View on Github external
now(): number {
        if (!this.statistics.enabled) {
            return -1;
        }
        if (!this.running) {
            throw new Error("Timer '" + this.name + "' has not been started");
        } else {
            const t = PerformanceTimer.now() - (this.m_currentValue || 0);
            return t;
        }
    }
}
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecoder.ts View on Github external
styleSetEvaluator,
            this.m_showMissingTechniques,
            this.m_featureFilter,
            this.m_featureModifier,
            this.m_gatherFeatureAttributes,
            this.m_createTileInfo,
            this.m_gatherRoadSegments,
            this.m_skipShortLabels,
            this.m_storageLevelOffset,
            this.m_enableElevationOverlay,
            this.languages
        );

        const decodedTile = decoder.getDecodedTile(tileKey, data);

        decodedTile.decodeTime = PerformanceTimer.now() - startTime;

        return Promise.resolve(decodedTile);
    }
github heremaps / harp.gl / @here / harp-examples / lib / PerformanceUtils.ts View on Github external
vendor: string;
        renderer: string;
    }

    enum StatisticsMode {
        None = 0,
        LastFrame = 1,
        All = 2
    }

    export interface FrameResults {
        renderedFrames: number;
        lastFrameStats?: SimpleFrameStatistics;
    }

    const appStartTime = PerformanceTimer.now();

    const DECODER_VALUES = [
        "decode.decodingTime",
        "decode.decodedTiles",
        "geometry.geometryCreationTime",
        "geometryCount.numGeometries",
        "geometryCount.numPoiGeometries",
        "geometryCount.numTechniques",
        "geometryCount.numTextGeometries",
        "geometryCount.numTextPathGeometries"
    ];

    const DEFAULT_THEME = {
        resource: "resources/berlin_tilezen_base.json"
    };