Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
MINOR: Added Berlin ZoomIn test and add save result option
Browse files Browse the repository at this point in the history
  • Loading branch information
Nino Kettlitz authored and ninok committed Mar 27, 2020
1 parent ba9b25b commit cb38e3b
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 21 deletions.
26 changes: 25 additions & 1 deletion @here/harp-examples/lib/PerformanceConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,31 @@ export namespace PerformanceTestData {
tilts: [0, 0, 0, 0, 0, 0],
numberOfDrawPoints: 250
};

export const BERLIN_ZOOM_IN = {
controlPoints: [
52.5,
13.4,
52.5,
13.4,
52.5,
13.4,
52.5,
13.4,
52.5,
13.4,
52.5,
13.4,
52.5,
13.4,
52.5,
13.4,
52.5,
13.4
],
zoomLevels: [12, 13, 14, 15, 16, 17, 18, 19, 20],
tilts: [0, 0, 0, 0, 0, 0, 0, 0, 0],
numberOfDrawPoints: 250
};
export const PARIS_ZOOM_IN_AND_OUT_2 = {
controlPoints: [
48.8566,
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-examples/lib/PerformanceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export namespace PerformanceUtils {
];

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

function getVendorFomContext(context: WebGLRenderingContext): GlInfo {
Expand Down
83 changes: 73 additions & 10 deletions @here/harp-examples/src/performance_benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import { GUI, GUIController } from "dat.gui";
import { PerformanceTestData } from "../lib/PerformanceConfig";
import { PerformanceUtils } from "../lib/PerformanceUtils";

interface ThemeList {
[name: string]: string;
}
// Theme list populated by webpack.config.js
declare const THEMES: ThemeList;

const logger = LoggerManager.instance.create("PerformanceUtils");

const NAME_NUM_DECODER_OPTION = "Num Decoders";
Expand Down Expand Up @@ -520,6 +526,22 @@ export namespace PerformanceBenchmark {
finishTest();
}

async function ZoomInBerlin() {
startTest("ZoomIn", "Berlin");
latestResult = await PerformanceUtils.measureFlyoverSpline(
mapViewApp,
"ZoomIn_Berlin",
PerformanceTestData.BERLIN_ZOOM_IN,
flyoverNumFrames,
false,
true,
showLabels,
flyoverNumRuns,
checkIfCancelled
);
finishTest();
}

async function ZoomInOutParis() {
startTest("ZoomInOut", "Paris");
latestResult = await PerformanceUtils.measureFlyoverSpline(
Expand Down Expand Up @@ -557,13 +579,7 @@ export namespace PerformanceBenchmark {
let settingUpGui = true;

const guiOptions = {
Theme: {
day: "resources/berlin_tilezen_base.json",
reducedDay: "resources/berlin_tilezen_day_reduced.json",
reducedNight: "resources/berlin_tilezen_night_reduced.json",
streets: "resources/berlin_tilezen_effects_streets.json",
outlines: "resources/berlin_tilezen_effects_outlines.json"
},
Theme: THEMES,
PixelRatio: {
default: undefined,
"1.5": 1.5,
Expand All @@ -572,6 +588,7 @@ export namespace PerformanceBenchmark {
},
CanvasSize: {
default: undefined,
"1100×900": "1100×900",
"640×400": "640×400",
"1024×768": "1024×768",
"1024×1024": "1024×1024",
Expand Down Expand Up @@ -631,7 +648,7 @@ export namespace PerformanceBenchmark {
"6": 6,
"8": 8
},
PhasedLoading: true,
PhasedLoading: false,
Berlin: () => {
openMapBerlin();
},
Expand Down Expand Up @@ -683,6 +700,9 @@ export namespace PerformanceBenchmark {
FlyOverEuropeLoaded: () => {
flyoverEuropeLoaded();
},
ZoomInBerlin: () => {
ZoomInBerlin();
},
ZoomInOutParis: () => {
ZoomInOutParis();
},
Expand All @@ -694,6 +714,9 @@ export namespace PerformanceBenchmark {
},
HideResults: () => {
hideTable();
},
SaveResults: () => {
saveTable();
}
};

Expand All @@ -708,7 +731,7 @@ export namespace PerformanceBenchmark {
mapViewApp.mapView.theme = newTheme;
});
})
.setValue("resources/berlin_tilezen_base.json");
.setValue(THEMES.default);

benchmarksFolder
.add(guiOptions, "CanvasSize", guiOptions.CanvasSize)
Expand Down Expand Up @@ -823,6 +846,7 @@ export namespace PerformanceBenchmark {
})
.setValue(undefined);

flyOversFolder.add(guiOptions, "ZoomInBerlin");
flyOversFolder.add(guiOptions, "ZoomInOutParis");
flyOversFolder.add(guiOptions, "ZoomInOutParis2");
flyOversFolder.add(guiOptions, "FlyOverNY");
Expand All @@ -842,6 +866,7 @@ export namespace PerformanceBenchmark {
cancelButton = gui.add(guiOptions, "Cancel");

gui.add(guiOptions, "HideResults");
gui.add(guiOptions, "SaveResults");

(cancelButton as any).domElement.setAttribute("disabled", "");

Expand All @@ -853,7 +878,9 @@ export namespace PerformanceBenchmark {
"mapCanvas",
["OMV"],
decoderCount,
powerPreferenceMap.get(powerPreference === undefined ? "Default" : powerPreference)
powerPreferenceMap.get(powerPreference === undefined ? "Default" : powerPreference),
undefined,
{ resource: THEMES.default }
);
if (mapViewApp.mainDataSource !== undefined) {
if (mapViewApp.mainDataSource.decoder instanceof WorkerBasedDecoder) {
Expand All @@ -876,6 +903,42 @@ export namespace PerformanceBenchmark {
tableDiv.style.display = "none";
}

function saveTable() {
const stats = latestResult;

let resultCSV =
"Name, Avg, Min, Max, Median, Med 75, Med 90, Med 95, Med 97, Med 99, Med 999\n";

const frameStatsStrings = Array.from(stats.frameStats!.keys()).sort();
for (const stat of frameStatsStrings) {
const frameStat = stats.frameStats!.get(stat)!;

const row = `${stat}, ${valueString(frameStat.avg)}, ${valueString(
frameStat.min
)}, ${valueString(frameStat.max)}, ${valueString(frameStat.median)}, ${valueString(
frameStat.median75
)}, ${valueString(frameStat.median90)}, ${valueString(
frameStat.median95
)}, ${valueString(frameStat.median97)}, ${valueString(
frameStat.median99
)}, ${valueString(frameStat.median999)}\n`;
resultCSV += row;
}
const type = "text/csv";
const blob = new Blob([resultCSV], { type });
const a = document.createElement("a");
const url = URL.createObjectURL(blob);
a.download = `results.csv`;
a.href = url;
a.dispatchEvent(
new MouseEvent(`click`, {
bubbles: true,
cancelable: true,
view: window
})
);
}

const million = 1024 * 1024;
const digits = 2;

Expand Down
37 changes: 28 additions & 9 deletions @here/harp-examples/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
* SPDX-License-Identifier: Apache-2.0
*/

const webpack = require("webpack");
const merge = require("webpack-merge");
const path = require("path");
const glob = require("glob");
const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const exampleFilter = process.env["FILTER_EXAMPLE"];

const exampleFilter = process.env["FILTER_EXAMPLE"];
const prepareOnly = process.env["PREPARE_ONLY"] === "true";

const harpMapThemePath = path.dirname(require.resolve("@here/harp-map-theme/package.json"));
Expand All @@ -19,6 +21,15 @@ const harpFontResourcesPath = path.dirname(require.resolve("@here/harp-fontcatal
const isProduction = process.env.NODE_ENV === "production";
const harpBundleSuffix = isProduction ? ".min" : "";

themeList = {
default: "resources/berlin_tilezen_base.json",
berlinDay: "resources/berlin_tilezen_base.json",
berlinReducedDay: "resources/berlin_tilezen_day_reduced.json",
berlinReducedNight: "resources/berlin_tilezen_night_reduced.json",
berlinStreets: "resources/berlin_tilezen_effects_streets.json",
berlinOutlines: "resources/berlin_tilezen_effects_outlines.json"
};

function resolveOptional(path, message) {
try {
return require.resolve(path);
Expand Down Expand Up @@ -83,7 +94,13 @@ const commonConfig = {
entrypoints: true,
warnings: true
},
mode: process.env.NODE_ENV || "development"
mode: process.env.NODE_ENV || "development",
plugins: [
new HardSourceWebpackPlugin(),
new webpack.DefinePlugin({
THEMES: JSON.stringify(themeList)
})
]
};

const decoderConfig = merge(commonConfig, {
Expand Down Expand Up @@ -154,13 +171,15 @@ const codeBrowserConfig = merge(commonConfig, {
}
});

browserConfig.plugins = Object.keys(browserConfig.entry).map(
chunk =>
new HtmlWebpackPlugin({
template: "template/example.html",
chunks: ["common", chunk],
filename: `${chunk}.html`
})
browserConfig.plugins.push(
...Object.keys(browserConfig.entry).map(
chunk =>
new HtmlWebpackPlugin({
template: "template/example.html",
chunks: ["common", chunk],
filename: `${chunk}.html`
})
)
);

const allEntries = Object.assign({}, webpackEntries, htmlEntries);
Expand Down

0 comments on commit cb38e3b

Please sign in to comment.