Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust (mid): Desmembrar o tipo Info, remover distance_matrix e remoção de comentarios desnecessarios #47

Open
wants to merge 8 commits into
base: mid
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ rust/main
rust/target/
subprocess
tempfile
distance_matrix

112,656 changes: 0 additions & 112,656 deletions distance_matrix

This file was deleted.

2 changes: 1 addition & 1 deletion mlp-instances
16 changes: 8 additions & 8 deletions rust/notas
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
10/03 - Utilização de arrays #d de tamanha fixo (500) alocados na heap (Box<T>) até então parece ser a melhor solução. Alguns resultados:
10/03 - Utilização de arrays #d de tamanha fixo (500) alocados na heap (Box<T>) até então parece ser a melhor solução. Alguns resultados:
rat99 1.89s
pr152 6.44s
gil262 45.52s
gil262 45.52s

14/03 - Utilização de arrays #d de tamanha fixo (300). Alguns resultados:
14/03 - Utilização de arrays #d de tamanha fixo (300). Alguns resultados:
rat99 1.80s
pr152 6.17s
gil262 42.13s
gil262 42.13s


obs: preciso verificar/trabalhar novamente a ideia do flat-vector (luc)
verificar tbm usar a funcao to_1D sem o parametro de referencia para tInfo.

-- Utilização de flat vector apenas na função subseq_load, com algumas tentativas de microotimização. Alguns resultados:
-- Utilização de flat vector apenas na função update_subseq_info_matrix, com algumas tentativas de microotimização. Alguns resultados:
standart into_boxed_slice
rat99 5.08s 5.00s
pr152 16.56s 20.36s
Expand All @@ -38,15 +38,15 @@
gil262 101.0s

17/03 - Comparacao entre o uso e o nao uso do metodo into_boxed_slice no vector.

Com uso:

rat99 3.21s
pr152 10.89s
gil262 71.51s

Sem uso:

rat99 3.21s
pr152 10.91s
gil262 72.62s
Expand All @@ -63,7 +63,7 @@
gil262 50.27s

29/03 - Comparação entre matriz vector e matriz array (uso de structs em ambos -- tSeqInfo) com uso do 'get_unchecked'.

MATRIX vector
rat99 1.82s
pr152 6.51s
Expand Down
32 changes: 9 additions & 23 deletions rust/src/data.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
use std::process::exit;
use std::fs;
use std::vec;
use std::fs::File;
use std::io::prelude::*;
use std::process::exit;
use std::vec;

fn print_type_of<T>(_: &T) {
println!("{}", std::any::type_name::<T>())
println!("{}", std::any::type_name::<T>())
}
Comment on lines 7 to 9
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover aq tbm ;`-)
Não vi que tinha duas.


pub fn load(dimension : &mut usize, c : &mut Vec<Vec<f64>>, rnd : &mut Vec<usize>) {
//pub fn load(dimension : &mut usize, c : &mut Vec<Vec<f64>>, rnd : &mut Vec<usize>) {

pub fn load(dimension: &mut usize, c: &mut Vec<Vec<f64>>, rnd: &mut Vec<usize>) {
let filename = "../distance_matrix";
//println!("In file {}", filename);

let contents = fs::read_to_string(filename)
.expect("Something went wrong reading the file");
let contents = fs::read_to_string(filename).expect("Something went wrong reading the file");

let mut line_i = 0;

let mut lines : Vec<String> = vec![];
let mut lines: Vec<String> = vec![];
for l in contents.lines() {
lines.push(l.to_string());
}

*dimension = lines[line_i].parse::<usize>().unwrap();
for k in 0..*dimension {c.push(vec![0.0; *dimension]);}
for k in 0..*dimension {
c.push(vec![0.0; *dimension]);
}
line_i += 1;

//print_type_of(&lines[line_i].parse::<usize>().unwrap());
//println!("{:?}", c[0]);

//exit(0);
//let mut l_i = -1;
for l_i in 0..*dimension {
let mut iter = lines[line_i].split_ascii_whitespace();
line_i += 1;
Expand All @@ -47,21 +40,14 @@ pub fn load(dimension : &mut usize, c : &mut Vec<Vec<f64>>, rnd : &mut Vec<usize
n = iter.next();
j += 1;
}
//print!("\n");
//l_i += 1;

}

line_i += 2;
//println!("{}", lines[line_i]);
let rnd_size = lines[line_i].parse::<usize>().unwrap();
line_i += 1;

for i in 0..rnd_size {
rnd.push(lines[line_i].parse::<usize>().unwrap());
line_i += 1;
}

//println!("{:?}", rnd);

}
Loading