1. function measureMetadataPerformance(metadata) {
  2. const startTime = performance.now();
  3. // Simulate metadata processing (replace with actual processing)
  4. let processedMetadata = JSON.parse(JSON.stringify(metadata)); // Deep copy for safety
  5. // Example: Iterate through the metadata
  6. for (const key in processedMetadata) {
  7. if (processedMetadata.hasOwnProperty(key)) {
  8. // Simulate some operation on each key-value pair
  9. const value = processedMetadata[key];
  10. if (typeof value === 'object' && value !== null) {
  11. for (const innerKey in value) {
  12. if (value.hasOwnProperty(innerKey)) {
  13. // Simulate processing inner key
  14. }
  15. }
  16. }
  17. }
  18. }
  19. const endTime = performance.now();
  20. const duration = endTime - startTime;
  21. return {
  22. duration: duration,
  23. processedMetadataSize: new TextEncoder().encode(JSON.stringify(processedMetadata)).length,
  24. };
  25. }
  26. if (typeof window === 'undefined') {
  27. module.exports = measureMetadataPerformance;
  28. }

Add your comment