React with Native

Bringing together React and React Native

GitHub

README

Measure performance

measure-performance (

OperationClassification

TODO: Ensure embedding this will embed the actual docs in my markdown renderer. I guess it might already do so!

TODO: It would be great to learn more about this topic and see if I can make more cross-environment packages. A great use case would be to create a wrapper around the current fs-orm to enable using it at the frontend too.

OperationClassification cjs)

Api reference
🔹 PerformanceItem

Properties:

NameTypeDescription
labelstring
durationMsnumber
cleanupTimer()

Ensure you run this after finishing the measurement, or you'll run into memory leaks!

Input
uniqueIdstring
Output
generateUniqueId()

Bit annoying that we need to use all model-types here xD.

TODO: Let's extrahere this

Input
-
OutputString
getNewPerformance()

Function that lets you measure performance inside any function with ease.

Usage:

Firstly, make a performance array, and a unique execution id, and start the measurement, like so:

import { generateUniqueId, getNewPerformance, PerformanceItem, cleanupTimer } from "measure-performance";

at the start of your function

const executionId = generateUniqueId();
const performance: (PerformanceItem | undefined)[] = [];
getNewPerformance("start", executionId, true)

After that, push a new performance item at every step you want to measure. Provide your label describing what happened before this (the step you are measuring).

performance.push(getNewPerformance("your label", executionId));

At the end of your function, you can view your performance array by printing it on the console (or store it somewhere if you like)

Don't forget to run

cleanupTimer

Ensure you run this after finishing the measurement, or you'll run into memory leaks!

cleanupTimer, or you'll run into memory leaks!

cleanupTimer(executionId);
Input
labelstring
Output{ label: string,
durationMs: number,
}
📄 cleanupTimer (exported const)

Ensure you run this after finishing the measurement, or you'll run into memory leaks!

📄 generateUniqueId (exported const)

Bit annoying that we need to use all model-types here xD.

TODO: Let's extrahere this

📄 getNewPerformance (exported const)

Function that lets you measure performance inside any function with ease.

Usage:

Firstly, make a performance array, and a unique execution id, and start the measurement, like so:

import { generateUniqueId, getNewPerformance, PerformanceItem, cleanupTimer } from "measure-performance";

at the start of your function

const executionId = generateUniqueId();
const performance: (PerformanceItem | undefined)[] = [];
getNewPerformance("start", executionId, true)

After that, push a new performance item at every step you want to measure. Provide your label describing what happened before this (the step you are measuring).

performance.push(getNewPerformance("your label", executionId));

At the end of your function, you can view your performance array by printing it on the console (or store it somewhere if you like)

Don't forget to run

cleanupTimer

Ensure you run this after finishing the measurement, or you'll run into memory leaks!

cleanupTimer, or you'll run into memory leaks!

cleanupTimer(executionId);