test.sh
This commit is contained in:
parent
0191d024e4
commit
a81950853e
4 changed files with 144 additions and 1 deletions
54
only.js
Normal file
54
only.js
Normal 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();
|
||||
Loading…
Add table
Add a link
Reference in a new issue