devel: performance timings

This commit is contained in:
2025-05-20 21:42:20 +02:00
parent 54a4a2cd5c
commit 9c7a30ca1c
3 changed files with 12 additions and 0 deletions

View File

@@ -18,6 +18,12 @@ open Maps
let sideEffectCmd fn arg = Elmish.Cmd.OfPromise.perform fn arg Noop
let sideEffectCmd' (fn: unit -> unit) = Elmish.Cmd.OfPromise.perform (fn >> Promise.lift) () Noop
[<Emit("performance.now()")>]
let perfNow () = jsNative
/// Used to gather timings of variable fetch -> drawn layer
let mutable t0: float = 0.0
let private logPos x = if x < 1.e-10f then -10.f else x |> float |> Math.Log10 |> single
let private logNeg x = if x < -1.e10f then -10.f else -x |> float |> Math.Log10 |> single
@@ -40,6 +46,7 @@ let updateWebglLayer model prop (layer: MapLayer) =
webglLayer.updateOpacity prop.Alpha
webglLayer.updateProps data
source.refresh ()
console.debug $"time: {(perfNow ()) - t0}"
)
}
|> Async.StartImmediate

View File

@@ -49,6 +49,7 @@ let fetchProp (model: Model) =
let prop = model.glLayers[Ocean]
async {
t0 <- perfNow ()
let! n = fvcomApi.Archive.GetNLayers aid
let l = if model.surface then 0 else n - 1
match prop.PropType with
@@ -68,6 +69,7 @@ let fetchCompressedProp (model: Model) =
let prop = model.glLayers[Ocean]
async {
t0 <- perfNow ()
let! n = fvcomApi.Archive.GetNLayers aid
let l = if model.surface then 0 else n - 1
match prop.PropType with

View File

@@ -9,6 +9,7 @@ async function decompress(compressedData, originalLength, tolerance) {
// Wait for wasm module to load
const Zfp = await Module();
const t0 = performance.now();
// malloc and memcpy compressed array into wasm heap
let compressed_p = Zfp._malloc(compressedData.length);
Zfp.HEAP8.set(compressedData, compressed_p);
@@ -21,6 +22,8 @@ async function decompress(compressedData, originalLength, tolerance) {
tolerance,
);
const t = performance.now();
console.log(`decompress: ${t - t0}`);
// Retrieve uncompressed data from wasm heap
return Zfp.HEAPF32.subarray(new_data_p / 4, new_data_p / 4 + originalLength);
}