Advertisement
Gygaweb

nodejs time to write strings array

Mar 10th, 2023
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.38 KB | Source Code | 0 0
  1. const { performance } = require('perf_hooks');
  2.  
  3. const start = performance.now();
  4.  
  5. // Escrever um array de string com 1000 elementos no console
  6. const arr = new Array(1000).fill().map((_, i) => `linha ${i+1}`);
  7. console.log(arr);
  8.  
  9. const end = performance.now();
  10. const timeInSeconds = ((end - start) / 1000).toFixed(6);
  11.  
  12. console.log(`Tempo de execução: ${timeInSeconds} segundos`);
Tags: nodejs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement