Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
¿Por qué es más lento copiar un Uint8Array en un Uint8ClampedArray que copiar un Uint8Array en un nuevo Uint8Array?

Parece que copiar un Uint8Array en un Uint8ClampedArray es mucho más lento que clonar el Uint8Array y usar su ArrayBuffer subyacente:

 const foo = new Uint8Array(0x10000000); // 256MiB console.time('Copy into Uint8ClampedArray'); const bar = new Uint8ClampedArray(foo); console.timeEnd('Copy into Uint8ClampedArray');

El código anterior registra ~160ms en mi máquina (Chrome v96, MacBook Pro).

 const foo = new Uint8Array(0x10000000); // 256MiB console.time('Clone, then use ArrayBuffer'); const bar = new Uint8ClampedArray(new Uint8Array(foo).buffer); console.timeEnd('Clone, then use ArrayBuffer');

El código de arriba registra ~70ms en mi máquina.

Firefox ofrece estadísticas similares (140 ms frente a 60 ms), mientras que Safari muestra diferencias más extremas (550 ms frente a 30 ms).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No estoy viendo esas diferencias de tiempo en el navegador o en NodeJs

 foo = new Uint8Array(256 * 1024**2); // 256MiB console.time(label = 'Copy into Uint8ClampedArray'); bar = new Uint8ClampedArray(foo); console.timeEnd(label); foo = new Uint8Array(256 * 1024**2); // 256MiB console.time(label = 'Clone, then use ArrayBuffer'); bar = new Uint8ClampedArray(new Uint8Array(foo).buffer); console.timeEnd(label);
 $ node -v && node test.js v17.2.0 Copy into Uint8ClampedArray: 174.049ms Clone, then use ArrayBuffer: 193.819ms $ node -v && node test.js v17.2.0 Copy into Uint8ClampedArray: 170.152ms Clone, then use ArrayBuffer: 192.41ms $ node -v && node test.js v17.2.0 Copy into Uint8ClampedArray: 168.555ms Clone, then use ArrayBuffer: 209.525ms
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!