function measureMetadataPerformance(metadata) {
const startTime = performance.now();
// Simulate metadata processing (replace with actual processing)
let processedMetadata = JSON.parse(JSON.stringify(metadata)); // Deep copy for safety
// Example: Iterate through the metadata
for (const key in processedMetadata) {
if (processedMetadata.hasOwnProperty(key)) {
// Simulate some operation on each key-value pair
const value = processedMetadata[key];
if (typeof value === 'object' && value !== null) {
for (const innerKey in value) {
if (value.hasOwnProperty(innerKey)) {
// Simulate processing inner key
}
}
}
}
}
const endTime = performance.now();
const duration = endTime - startTime;
return {
duration: duration,
processedMetadataSize: new TextEncoder().encode(JSON.stringify(processedMetadata)).length,
};
}
if (typeof window === 'undefined') {
module.exports = measureMetadataPerformance;
}
Add your comment