This commit is contained in:
PanSi21 2025-01-05 19:44:43 +01:00
parent 0191d024e4
commit a81950853e
Signed by untrusted user who does not match committer: PanSi21
GPG key ID: 755F8874C65EF462
4 changed files with 144 additions and 1 deletions

54
only.js Normal file
View file

@ -0,0 +1,54 @@
const setN = 500; // Imposta la dimensione della matrice
// test matrix JS
function matrixjs( n = setN) {
let a = [];
let b = [];
let c = [];
for (let i = 0; i < n; i++) {
a[i] = [];
b[i] = [];
c[i] = [];
for (let j = 0; j < n; j++) {
a[i][j] = Math.floor(Math.random() * 100);
b[i][j] = Math.floor(Math.random() * 100);
c[i][j] = 0;
}
}
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
for (let k = 0; k < n; k++) {
c[i][j] += a[i][k] * b[k][j];
}
}
}
for (let i = 0; i < n; i++) {
a[i].length = 0;
b[i].length = 0;
c[i].length = 0;
}
a.length = 0;
b.length = 0;
c.length = 0;
}
// Funzione per misurare il tempo di esecuzione
function jsTest() {
const start = performance.now();
// Esegui la funzione matrixjs
matrixjs(setN);
const end = performance.now();
console.log(`JavaScript Execution Time: ${end - start}ms`);
}
// Avvia il benchmark
jsTest();