-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.js
55 lines (43 loc) · 1.81 KB
/
Main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const ManipulateFiles = require('./src/scripts/ManipulateFiles');
const SortsTime = require('./src/scripts/SortsTime');
// const CreateAverage = require('./src/scripts/CreateAverage');
const BubbleSort = require('./src/scripts/Sorts/BubbleSort');
const InsertionSort = require('./src/scripts/Sorts/InsertionSort');
const QuickSort = require('./src/scripts/Sorts/QuickSort');
const SelectionSort = require('./src/scripts/Sorts/SelectionSort');
const MergeSort = require('./src/scripts/Sorts/MergeSort');
let files = new ManipulateFiles();
async function main(totalTables = 5){
let database = ["random", "growing", "degrowing"];
let quantities = [10000,20000,30000,100000,200000,300000,1000000];
let funcs = [BubbleSort, InsertionSort, QuickSort, SelectionSort, MergeSort];
let totalDB = await files.listFiles('./src/database');
let totalDirCsv = await files.listFiles('./src/database/CSVs');
if(totalDB.length-2 === 0){
SortsTime("random", 1000000, MergeSort, true);
}
if(totalDirCsv.length < funcs.length){
for(let i in funcs){
await files.createDIR(funcs[i].name);
}
}
for(let table = 0; table < totalTables; table++){
await Start(funcs, quantities, database, table);
}
// CreateAverage();
}
async function Start(funcs, quantities, database, table){
for (let i in funcs){
await files.createCSV(funcs[i].name,`${funcs[i].name}Tabela0${table+1}.csv`);
for(let j in quantities){
let auxSend = [];
for(let k in database){
let send = SortsTime(database[k], quantities[j], funcs[i]);
auxSend[0] = send.name_function;
auxSend.push([send.runtime]);
}
files.setCSV([...auxSend, quantities[j]], table);
}
}
}
main();